0

/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

If i run this file directly in browser - all fine

What i did :

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  ]

Will be pleased for any help

UPDATE

latest lines from \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 from command line works

UPDATE 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 script:

<?php
    mail('[email protected]', 'cron test', 'Some message');    
?>

Solved. I have wrote it at wrong file Correct file: /var/spool/dorsen

1 Answer 1

2

/etc/crontab has a different format. Note the "root" in the 6th field. For /etc/crontab, the 6th field is for the user you want the job to execute as.

So, something like:

*/2 * * * * dorsen /usr/bin/php -q /home/dorsen/public_html/cron-test.php

is the right format, executing that job as "dorsen".

Your second form, with the URL, is really not going to work, as there's no such thing as http://www.mysiteurl.com/cron-test.php in your execution path.

3
  • */2 * * * * dorsen /usr/bin/php -q /home/dorsen/public_html/cron-test.php doesn't work either. Owner and group of this file is dorsen
    – johnode
    Jun 1, 2012 at 10:52
  • I assume running /usr/bin/php -q /home/dorsen/public_html/cron-test.php from the command line works? Is there anything in the relevant log file?
    – cjc
    Jun 1, 2012 at 11:15
  • Since it's working, is there anything in the php script that references things outside the specified PATH?
    – cjc
    Jun 1, 2012 at 11:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .