Ubuntu Server 12.04. I use:
sudo crontab -e * * * * * root /etc/init.d/apache2 restart > /dev/null 2>&1 sudo restart cron
And it doesnt work. How to fix it? So many docs in google,I need one "true way".
I'm assuming that you have exited the cron tab after the 2nd statement. That third line won't work in crontab. Cron should reload itself.
The issue with your cron tab is that you have it set to run every minute of every hour of every day ect. That what the * means, all options.
View this in coumn format
This is the the 0th minute of the 1st hour, every day.
Restart apache is a bad idea, maybe you can just reload? Or check apache status and restart if apache is down.
and cron job will be
And first of all, when you want to restart apache in scripts, you must check configuration file for errors.
To become more familiar with the crontab timing commands you could try the Cron Sandbox.
Time/date parameters go in and a list of future run-times comes out.