I'm using Plesk 12 + CentOS 6.
I ssh into root
account and use crontab -e
to create the following entry:
* * * * * service httpd restart
I expect it to restart apache every minute (just to test/debug it's working)
I checked the apache status using service httpd status
and the PID is always the same, and apache is not restarting.
I verified /var/log/cron
that the command is being executed.
Feb 7 16:11:01 srv104 CROND[15620]: (root) CMD (service httpd restart)
However, all other entries in the crontab
are correctly executing.
If I execute the command service httpd restart
manually in shell terminal, apache is restarting correctly with a new updated PID.
Is there any preventive measure in place such that service
can't be executed in root cronjob
?
Why is my crontab not working, and how can I troubleshoot it? has some useful tips, but does not address my specific situation mentioned in the original question above.
Working Solution:
If I specify the full path to the /sbin/service
, eg. /sbin/service httpd restart
in the cronjob, as mentioned in the accepted answer, it does work.
Not sure if it's operating system version related, but simply with the PATH
in place in /etc/crontab/
does not help in my situation.