What happens to a 2:30 Cronjob if the server goes down at 2:28 and only comes back 5 minutes later?

Asked

Viewed 268 times

14

I don’t know if the question is confusing, but is that I have used a lot of Cronjob in my systems currently and do not want to have problems. So I’m going to illustrate my concern with a hypothetical situation.

Suppose I have a Cronjob programmed to run 2:30 morning. However, the server provider had to go into maintenance (or gave some internal problem) and shut down the server 2:28 morning. But 5 minutes later, ie, 2:32, the service was restored.

What will happen to that schedule of 2:30? Will it run when the machine starts? Or it will be completely ignored, running only the other day?

I need to know this because I have some scripts that have specific dates or times to run, and I don’t want to have harm with information and events from my systems.

If the answer is yes to "will be ignored?" , how can I check if the server was restarted and if a cron was not executed at a certain time and then run?

  • 2

    A doubt I’ve always had. + 1, it’s also something I’d like to know on Windows-Server, if there is any situation in the task scheduler.

  • Yes is possible also for Windows Server, the equivalent of Cronjob would be the Task Scheduler. For more information check this link : https://en.wikipedia.org/wiki/Windows_Task_Scheduler

  • @Falion I think you misunderstood me, I want to know if the problem can occur in Windowsserver, if he performs the task even if the time has passed, for example the machine was off 30 minutes and in that time had a task =) basically the same question of Wallace, but in windowsserver, thank you

  • @Guilhermenascimento So, the equivalent of the Windows Server is the Task Scheduler and it as well as others follows the same pattern as the Linux Cron, if the machine is turned off for example 30 minutes and at that time had a task,He takes it as a principle that the system goes on 24 hours without stopping. This is why it is recommended to use services other than Cronjob to avoid errors like this.

  • What language are you working on? If it’s something web, can you show me how to do it on this side ;)

  • @Fábio yes sir, I work with Web. PHP :)

Show 1 more comment

1 answer

11


Simple, it will not be executed because the Cronjob ignores a service that has passed the timetable and where the system was not working and will only run on another day normally (if the same situation does not occur).

On Linux, users use Crontab, but for better performance of the scheduled system it is also good to use a program called Anacron.

The Anacron is a program that helps you schedule specific intervals in the day, so along with Cron you can make sure you no longer have these scheduling errors, since Cron assumes that the system works 24 hours a day.

To know how to use Cron with Anacron I suggest you read this article that explains how to use :

http://www.tuxradar.com/content/automate-linux-cron-and-anacron

And for more information on Anacron visit :

http://anacron.sourceforge.net/

To monitor the time of shutdown of a Linux Server :

https://www.vivaolinux.com.br/dica/Monitorando-hora-de-desligamento-de-servidores-Linux

To know if your Cron is running normally :

http://www.inmotionhosting.com/support/website/cron-jobs/did-cron-job-run

Browser other questions tagged

You are not signed in. Login or sign up in order to post.