/etc/crontab:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
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
*/2 * * * * /usr/bin/php -q /home/dorsen/public_html/cron-test.php
*/2 * * * * http://www.mysiteurl.com/cron-test.php - also doesn't work
如果我直接在浏览器中运行此文件-一切都很好
我做了什么 :
root@vded10625 [~]# yum remove cronie-anacron
....
Complete!
root@vded10625 [~]# yum install cronie-noanacron sysstat
....
Complete!
root@vded10625 [~]# service crond start
Starting crond: [ OK ]
root@vded10625 [~]# chkconfig crond on
root@vded10625 [~]# service crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
很高兴能得到任何帮助
更新
来自 \var\log\cron 的最新行:
Jun 1 12:12:03 vded10625 crontab[8910]: (root) BEGIN EDIT (root)
Jun 1 12:15:01 vded10625 CROND[9138]: (root) CMD (/usr/local/cpanel/scripts/recoverymgmt >/dev/null 2>&1)
Jun 1 12:15:01 vded10625 CROND[9139]: (root) CMD (/usr/local/cpanel/bin/dbindex >/dev/null 2>&1)
Jun 1 12:15:01 vded10625 CROND[9137]: (root) CMD (/usr/local/cpanel/bin/dcpumon >/dev/null 2>&1)
Jun 1 12:15:01 vded10625 CROND[9141]: (root) CMD (/usr/local/cpanel/scripts/autorepair recoverymgmt >/dev/null 2>&1)
Jun 1 12:18:01 vded10625 CROND[9335]: (root) CMD (/usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1)
Jun 1 12:20:01 vded10625 CROND[9470]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Jun 1 12:20:01 vded10625 CROND[9471]: (root) CMD (/usr/local/cpanel/bin/dcpumon >/dev/null 2>&1)
Jun 1 12:20:26 vded10625 crontab[8910]: (root) END EDIT (root)
/usr/bin/php -q /home/dorsen/public_html/cron-test.php通过命令行工作
更新2
crontab-l:
0 6 * * * /usr/local/cpanel/scripts/exim_tidydb > /dev/null 2>&1
52 21 * * * /usr/local/cpanel/scripts/upcp --cron
0 1 * * * /usr/local/cpanel/scripts/cpbackup
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
45 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_mailman_cache && /usr/local/cpanel/scripts/update_mailman_cache
30 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_db_cache && /usr/local/cpanel/scripts/update_db_cache
45 */8 * * * /usr/bin/test -x /usr/local/cpanel/bin/optimizefs && /usr/local/cpanel/bin/optimizefs
30 */2 * * * /usr/local/cpanel/bin/mysqluserstore >/dev/null 2>&1
15 */2 * * * /usr/local/cpanel/bin/dbindex >/dev/null 2>&1
15 */6 * * * /usr/local/cpanel/scripts/recoverymgmt >/dev/null 2>&1
*/5 * * * * /usr/local/cpanel/bin/dcpumon >/dev/null 2>&1
6 21 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl --notify
3,18,33,48 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1
2,58 * * * * /usr/local/bandmin/bandmin
0 0 * * * /usr/local/bandmin/ipaddrmap
15 */6 * * * /usr/local/cpanel/scripts/autorepair recoverymgmt >/dev/null 2>&1
30 5 * * * /usr/local/cpanel/scripts/optimize_eximstats > /dev/null 2>&1
PHP脚本:
<?php
mail('[email protected]', 'cron test', 'Some message');
?>
解决了。 我把它写在了错误的文件中 正确的文件:/var/spool/dorsen
答案1
/etc/crontab 的格式不同。请注意第 6 个字段中的“root”。对于 /etc/crontab,第 6 个字段是您希望以哪个用户身份执行该作业。
因此,类似于:
*/2 * * * * dorsen /usr/bin/php -q /home/dorsen/public_html/cron-test.php
是正确的格式,以“dorsen”的形式执行该作业。
您的第二种形式,带有 URL,实际上是行不通的,因为http://www.mysiteurl.com/cron-test.php
在您的执行路径中没有这样的东西。