3

I want to run a cronjob once every day on a machine that doesn't run all the time, but runs at least once a day for a couple of hours. The problem with a cronjob is, that I have to give it the exact time, when it is supposed to run, but my machine may not be running at this particular time. I know there is an option to cron that says "do this, when booting" but my machine usually isn't rebooted, but I leave it in standby. Put differently, I want to execute something once a day, but I can't give an exact time. Is there a solution to this?

2 Answers 2

4

You want something like anacron:

anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days) on systems that don't run 24 hours a day.

Available as packages in most Linux distributions. There's probably also a port for MS Windows...

1
  • This is the answer. Perfect
    – sinni800
    Feb 2, 2011 at 11:44
0

You could invoke the job from a startup script in /etc/rc2.d which compares today's date with one saved in a file and then updates that file.

You must log in to answer this question.

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