Tuesday, May 5, 2015

cron - crontab doesn't work on centos 6

/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:



    mail('mymail@gmail.com', 'cron test', 'Some message');    

?>


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

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...