我有PHP脚本我试图执行常规使用cron。在CentOS上的Cron没有正确执行一个PHP脚本
我正在通过修改crontab文件来做到这一点。
crontab的内容:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/10 * * * * root /usr/bin/php /var/www/html/cron_update_statuses_one_hour.php
0 */03 * * * root /usr/bin/php /var/www/html/cron_update_statuses_three_hour.php
0 */08 * * * root /usr/bin/php /var/www/html/cron_update_statuses_eight_hour.php
0 */16 * * * root /usr/bin/php /var/www/html/cron_update_statuses_sixteen_hour.php
0 0 * * * root /usr/bin/php /var/www/html/cron_update_statuses_one_day.php
的cron日志:
Jul 13 00:10:01 s1 CROND[2944]: (root) CMD (cd /var/www/html/ /usr/bin/php cron_update_statuses_one_hour.php)
Jul 13 00:12:01 s1 crond[2124]: (*system*) RELOAD (/etc/crontab)
Jul 13 01:00:01 s1 CROND[2977]: (root) CMD (/usr/sbin/raid-check)
Jul 13 01:01:01 s1 CROND[2992]: (root) CMD (run-parts /etc/cron.hourly)
Jul 13 01:01:01 s1 run-parts(/etc/cron.hourly)[2992]: starting 0anacron
Jul 13 01:01:01 s1 anacron[3001]: Anacron started on 2014-07-13
Jul 13 01:01:01 s1 run-parts(/etc/cron.hourly)[3003]: finished 0anacron
Jul 13 01:01:01 s1 anacron[3001]: Jobs will be executed sequentially
Jul 13 01:01:01 s1 anacron[3001]: Normal exit (0 jobs run)
Jul 13 01:07:01 s1 crond[2124]: (*system*) RELOAD (/etc/crontab)
Jul 13 01:10:01 s1 CROND[3022]: (root) CMD (/usr/bin/php /var/www/html/cron_update_statuses_one_hour.php)
Jul 13 02:01:01 s1 CROND[3059]: (root) CMD (run-parts /etc/cron.hourly)
Jul 13 02:01:01 s1 run-parts(/etc/cron.hourly)[3059]: starting 0anacron
Jul 13 02:01:01 s1 anacron[3068]: Anacron started on 2014-07-13
Jul 13 02:01:01 s1 anacron[3068]: Jobs will be executed sequentially
Jul 13 02:01:01 s1 anacron[3068]: Normal exit (0 jobs run)
Jul 13 02:01:01 s1 run-parts(/etc/cron.hourly)[3070]: finished 0anacron
Jul 13 02:10:01 s1 CROND[3072]: (root) CMD (/usr/bin/php /var/www/html/cron_update_statuses_one_hour.php)
100%确保PHP的位置是正确的; 100%确定cron服务正在运行; 100%确定我的脚本的位置是正确的
此外,是的,我意识到我的第一个条目设置为每隔10分钟运行一次该命令,我只是为了调试目的,请假装其设置为每运行一次小时
请大家帮忙* nix专家Big Grin | :-D!
谢谢
一般来说,首先检查cron问题是所有的环境变量。 crond不会以用户身份登录,因此.profile等等可能未被执行。从命令行执行set> /tmp/set.1。运行命令set> /tmp/set.2作为cron作业。比较这两个文件 –