0

As mentioned in another question here: Job scheduling using crontab, what will happen when computer is shutdown during that time? that Cron jobs will not work during shutdown/restart case and we can use Anacron for such situations

For my case, there are lots of Cron jobs scheduled and chances of host restart is minimal that is once-twice a year and the hosts are up and running for the rest of the time and changing from Cron to Anacron may not be necessary. My cron tasks are assigned on the CentOS machine. Is there a way out?

I'm new to Cron tool. Any idea in the right direction will do!

Aadil Hoda
  • 103
  • 4

1 Answers1

2

There are some nice alices for man (5) crontab, one of them is "@reboot".

You can use it to have it run when the system is started, and then another job for the specific date perhaps?

@reboot <path to job>
0 5 1 6,12 0 <path to job>

This would run the job at reboot AND 05:00 month 6 and 12 on the first day of the month.

A more complicated solution would be to have the cronjob create a file when run, and then you could check for the existence of that file when you boot to see if it's needed to run again or not, say after X days has passed since the file was created, but I leave you to think about that depending on your need.

Fredrik
  • 528
  • 2
  • 10