LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   outdated cronjobs (http://www.linuxquestions.org/questions/linux-software-2/outdated-cronjobs-349573/)

bujecas 08-03-2005 10:04 AM

outdated cronjobs
 
Hello, I have some scripts running in a cronjob. One of them runs at 07:00. The machine shuts down at 05:00 and reboots at 10:00. The cronjob of 07:00 didn't start.

It's possible to run the outdated cronjob when the machine reboots? How?

note: I'm using vixie cron.

trickykid 08-03-2005 10:21 AM

Is this a daily thing or ongoing reboot type thing? If so, why dont you just move your crons that should be running during downtime to another time? If not and only a rare occasion, just manually run them would be the easiest way.

bujecas 08-03-2005 12:13 PM

It's a daily thing. The problem is that I want the outdated script running when the machine comes up and I may not be available at that time. I want that the machine launch the script automaticaly, not by my hand.

trickykid 08-03-2005 04:57 PM

Quote:

Originally posted by bujecas
It's a daily thing. The problem is that I want the outdated script running when the machine comes up and I may not be available at that time. I want that the machine launch the script automaticaly, not by my hand.
If you have your machine shutdown at 05:00 and rebooted at 10:00, why not have the cron kickoff at like 10:10? If you know your system is down for 5 hours each day, I find it pointless to work around any cron jobs you have setup to run during that time when the machine isn't even running. Why make things harder than they have to be? :confused:

Or if you definitly want these to run right at bootup, why not set them up in your startup scripts?? I think your making this more complicated than it really is.

bujecas 08-04-2005 05:35 AM

Your're not getting my point. The machine doesn't shuts down every day at 05:00 and boots at 10:00, that was an example. The point is if the power fails and the machine goes down for a indeterminated period, there must be a mechanism to start the cronjobs that were supposed to run at that dead period.

Vgui 08-04-2005 11:17 AM

You could write a quick script to just run _all_ cron jobs on a reboot, or try to figure out (based on the current time and the last shutdown time) if any didn't get run.
I'd say it's doable through bash scripting though, but there isn't a magic program (that I'm aware of) that can "queue" up cron jobs or anything like that.

trickykid 08-04-2005 11:24 AM

Quote:

Originally posted by bujecas
Your're not getting my point. The machine doesn't shuts down every day at 05:00 and boots at 10:00, that was an example. The point is if the power fails and the machine goes down for a indeterminated period, there must be a mechanism to start the cronjobs that were supposed to run at that dead period.
I guess when you say: "It's a daily thing" kind of threw me off thinking that it actually happens daily.. :confused:

Well, you'll need to write a script that checks what crons ran and which one's didn't during a downtime period.. verify against the times in your crontab and then most likely in the logs. Then have that script run at startup to verify and run what is necessary, etc. But you'll definitly need to make sure all your cron jobs create some type of output in a log or make the script check when the last time the server shutdown and then started up, take that downtime period and check it against your cron entries and kick off anything that fell in that downtime window..


All times are GMT -5. The time now is 05:19 PM.