Unable to run Cron Jobs - PHP

Status
Not open for further replies.

xnagarohit62

New Member
Messages
7
Reaction score
0
Points
0
Hi all, Kindly help me in setting up a cron job..
initially i tried with setting up a simple script that just sends out a mail every time it is run.. I waited patiently for any reply from my inbox but it was in vain.. :frown:
I used these commands:
/usr/local/bin/php /home/xsnr/public_html/test/cron.php
and php /home/xsnr/public_html/test/cron.php

Neither of which worked. Then i tried setting up a script with just an "echo" statement, set up the mail id from the cpanel and then again waited patiently again in vain..

I tried with settings or running every minute (for testing purpose) and run every 10 minutes again in vain.. Is cron working ??
 

Skizzerz

Contributors
Staff member
Contributors
Messages
2,928
Reaction score
118
Points
63
We have restrictions on cron jobs on Free Hosting in that you may only have one cron running every 5 minutes. This means that a minute cron is straight disallowed, and if you have more than 1 cron job, you need to time them so that they are at least 5 minutes apart.

Check your mail settings as well in that script, to make sure you aren't trying to forge any email headers, as that is also blocked by our server. The email account you are putting in the From: field should be an email account that exists on your cPanel

Finally, use the following as a command (this logs output to a cron.log file in your home directory):
php /home/xsnr/public_html/test/cron.php >> /home/xsnr/cron.log 2>&1
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
/usr/local/bin/php /home/xsnr/public_html/test/cron.php  >>/home/xsnr/public_html/test/cron_log.txt 2>&1

For testing, use every 5 minutes. The system is set up to delete 1 minute jobs. This puts any output (echo) or error messages into cron_log.txt . The mail notification system has been turned off.
 

xnagarohit62

New Member
Messages
7
Reaction score
0
Points
0
@Skizzerz and @descalzo: Thanks for your replies.. heres what i got a trace on the log file generated by the above cron as indicated by the command " /usr/local/bin/php /home/xsnr/public_html/test/cron.php >>/home/xsnr/public_html/test/cron_log.txt 2>&1 "

Can't do setuid (cannot exec sperl)

Please help..
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
You are trying to use mail() in the script. For some reason it throws that error for everybody.

Alternative is to run the script from the Web via wget.

Code:
wget -O -  http://yourURL/test/cron.php?key=67ni8eadn9969 >>/home/xnrs/public_html/test/cron_log.txt 2>&1

Add a bit of code at the top of your script to test 'key' (change to your own random string) so it won't get called by accident.

And the -O is "capital oh", not "zero"
 
Last edited:
Status
Not open for further replies.
Top