Hi Guys, We are setting cron job on our server. Content of crontab file is like below mentioned SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="mayur_oak@os2idomain.com" HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly 57 12 * * * wget http://192.168.0.31/extranet/cronjob/activitiesexp.php -O /dev/null 58 12 * * * wget http://192.168.0.31/extranet/cronjob/announcementexp.php -O /dev/null 59 12 * * * wget http://192.168.0.31/extranet/cronjob/contractexp.php -O /dev/null 01 13 * * * wget http://192.168.0.31/extranet/cronjob/empassignmentexp.php -O /dev/null 02 13 * * * wget http://192.168.0.31/extranet/cronjob/notice_exp.php -O /dev/null 03 13 * * * wget http://192.168.0.31/extranet/cronjob/vacancyexp.php -O /dev/null * * * * * wget http://192.168.0.31/extranet/cronjob/client_flag.php -O /dev/null though cron job is getting set the changes are not being reflected in database (i mean it might not be running). But if i run the command wget http://192.168.0.31/extranet/cronjob/client_flag.php -O /dev/null it is running perfectly with reflecting changes in the database. So please let me know where we are going wrong? Thanks in advance. Regards, Mayur
On cron jobs you have to put in a command to run. In your case to run the php files use this command. php /home/username/public_html/phpfile.php Code (markup):
You might need to change the working directory for cron as well. Scripts fired off by cron do not inherit your bash's (or whatever shell you use) environmental variables (a sub-shell is spawned for cron processes), perhaps one or more needed env variables are missing? You might need to look at using something like notty.c too. Best of luck, cron can be a bear sometimes but all around it sure is a great tool.
Running php from the command line can be pretty finicky as LinketySplit mentioned. Our product uses a cron job in order to work correctly, and this is likely the most frequently "ticketed" item we get for support requests. If you are not using Zend Optimizer, this format typically works 95% of the time: cd [PATHTOSCRIPT]/; [PATHTOPHP]/php -f activitiesexp.php For example: cd /home/admin/domains/yourdomain.com/public_html/background/; /usr/local/bin/php -f activitiesexp.php Code (markup): Hope that helps! -Bing