Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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?
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.
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.
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.
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..
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..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.