5

I use fedora20 and its default cron. I have a cron job script that puts the server to sleep at 10:30am with rtcwake, and it wakes up at 12:30pm. If I run the script manually at 9:40am, it will also wake up at 12:30pm. If I run the script manually at 9:40am, will it run the missed cron task at 10:30am after wake up at 12:30pm and goes to sleep right away(which makes it wake up at 3:30pm)?

That seems to be what is happening with my server, and I want to know if the cron runs the missed job after wakeup. If so, is there any way to change this behavior? Thank you very much.

2 Answers 2

3

Fedora defaults to chronie, which incorporates anacron-like functionality to run jobs periodically even when the system is off. The defaut /etc/anacrontab looks like this:

#period in days   delay in minutes   job-identifier   command
1       5       cron.daily              nice run-parts /etc/cron.daily
7       25      cron.weekly             nice run-parts /etc/cron.weekly
@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly

... which means that by default any scripts you put into one of those directories (/etc/cron.[daily,weekly,monthly]) will run even if the computer is off. However, stuff in /etc/crontab or /etc/cron.d or user crontabs won't work that way. Look at man anacrontab for how to add new entries, if the existing periodic schedules don't work for you.

1
  • 1
    Thank you very much for the answer. I just found out it uses anacron. And my script is in the root crontab. But there is another entry at 1:30pm in root cron to put it to sleep till 3:30pm. But that 1:30pm missed cronjob does not get executed at 3:30pm when it wakes up. So, if I manually put the server to sleep at 9:40, the skipped job at 10:30 gets run when it wakes up at 12:30, and goes to sleep at 12:31, but 1:30 skpped job does not run at 3:30pm when it is up. Is there any rules regarding this? Thank you very much. Jun 1, 2017 at 23:55
2

Not all cron daemons handle cases for noncontinuous uptime. One which is specifically designed to run "missed" jobs is anacron.

2
  • Thank you for the reply. How do I find if fedora cron runs missed job or not? If I run the script manually 9:40am, it wakes up at 12:30pm and goes to sleep right away at 12:31pm. And the only reason for this seems to be the missed cron job at 10:30am. Thank you.. Jun 1, 2017 at 20:11
  • Fedora (probably) has a selection/choice of crons. Use the package manager to find out which one(s) is/are installed. Jun 1, 2017 at 20:32

You must log in to answer this question.

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