unable to run php cron jobs

Status
Not open for further replies.

amitgad

New Member
Messages
27
Reaction score
0
Points
1
Hi,

I have been facing this issue since more than a month now. The issue is i have scheduled a php cron job that used to run perfectly earlier, but now it doesnt run.

To test the functionality, i have set up a test cron job @
http://amit.exofire.net/test2/appl/php.php

that runs every hour and sends out a test mail.

The command i'hv used is-
/usr/local/bin/php /home/amitgad/public_html/test2/appl/php.php

further when i run the php file directly from internet explorer it works and sends out the mail. but when i schedule it using cron jobs, it doesnt even run.

Please guide me on this if I'm missing here something or if you have changed any settings.


Thanks
Amit
 

amitgad

New Member
Messages
27
Reaction score
0
Points
1
hello!
anyone has any answer for this...
will help me a lot....
thanks
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
try changing to: /usr/bin/php /home/amitgad/public_html/test2/appl/php.php

Note the changed path for php.
 

amitgad

New Member
Messages
27
Reaction score
0
Points
1
Hey Anna...
thanks for the help..but I'm afraid it doesn't work either!
i guess there was some change made to the cron jobs..probably in dec-jan...because it was working earlier!!
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
Only thing that might be changed is that php mail() needs to have the content type text/plain
 
Last edited:

amitgad

New Member
Messages
27
Reaction score
0
Points
1
thanks,
but if i click the above link, it sends out the mail and if i schedule it for cron jobs, it doesnt run. So I'm not sure if mail function is giving problems. Nevertheless, i have given the php code for the above script below-

PHP:
<?php

$ip=$_SERVER['REMOTE_ADDR'];
$from = "JobScheduler";
$to = "xxx@abc.com";
$subject = "hello test msg";
$message = "Hello test" . "\n your ip address is: $ip";
$headers = 'From: ' . $from . "\r\n" . 'Reply-To: ' . $from . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

// Send
if (mail($to, $subject, $message, $headers)) {
    echo "-->mail sent";

echo "<b>IP Address= $ip</b>";

} else {
    echo "failed";
}
?>
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP mail() does not work properly when run as a cron job, period.
 

amitgad

New Member
Messages
27
Reaction score
0
Points
1
okay....but is there anyway around to make this work, because i need this for my app to work. I would be very thankful.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. Get Google Apps account for your domain
2. Follow their instructions to use cPanel to set MX records to Google. All incoming mail will be routed to Google Apps account
3. Download and use PHPMailer to send your outgoing mail via STMP thru your Google Apps account.
 
Status
Not open for further replies.
Top