What is the proper way to restart anacron? I want to set it up to restart every hour. Would a crontab entry like do the job?

sudo crontab -e
@hourly anacron

Why is anacron initially started by default from in the /etc/crontab and not in the sudo crontab?

link|improve this question
4  
Why do you need to do this? – Shane Madden Jan 5 at 6:33
I'll second the question, what is it you are trying to accomplish? – mdpc Jan 5 at 6:51
I am trying to accomplish this askubuntu.com/questions/92322/… – ECII Jan 5 at 7:05
1  
You may do that, but i dont understand why?, if you want to change the hour of your daily tasks execution you should change /etc/crontab to reflect your preferenes. To create a task specifically for anacron change /etc/anacrontab. For running things at midnight you may try with @midnight or @daily, both are shortcuts for 0 0 * * *. – Pablo Castellazzi Jan 5 at 10:30
The problem is that I dont know the time the backup pc will be up and I dont know the time that the backup drive will be mounted. So I want every day and as soon as possible to run the backup script as long as the server is up and the drive mounted. Thats why i though maybe to run the anacron every hour... – ECII Jan 8 at 9:20
feedback

closed as not constructive by mdpc, Khaled, Zoredache, Iain, voretaq7 Jan 14 at 5:32

This question is not a good fit to our Q&A format. We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion. See the FAQ for guidance on how to improve it.

1 Answer

From you question if I can understand well you want to accomplis the following. Running a script once a day as soon as possible. If it is the case I would do this:

 * * * * * if [ "`cat /lastrun.txt`" != "`date +%F`" ]; then echo "run command"; date +%F > /lastrun.txt; fi

This will run the check every minute if the script already runned and if not it runs it.

link|improve this answer
why not just use 0 0 * * * ? – Iain Jan 5 at 21:51
If the machine booted during the day it will run the script at next midnight, won't it? – Stone Jan 5 at 22:00
Isnt this what anacron is supposed to do? – ECII Jan 8 at 9:19
Sorry I was thinking about cron not anacron. – Stone Jan 8 at 22:08
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.