How can jobs be run at specific reoccurring dates without assuming the computer is never asleep?
I would like to find a way to execute tasks on specific reoccurring dates, for example send a message every April Fool's Day, without assuming the machine is running and not sleeping. Edit: by this, I mean if the system is sleeping or not running, the command should be executed once it starts running again.
The at command fails at this, as it does not seem to allow a command to be executed reletedly and endlessly (unless you use some sort of self-replicating program). Cron fails, as it assumes the system is constantly up. Anacron fails, as it can only schedule jobs to run within an interval, but I don't think you can specify a single day in a year to run. Fcron seems to fail, as though it can execute tasks even if the computer was shit down during the time they were supposed to be executed, it does not seem to execute jobs if the computer is sleeping during the time they are supposed to be executed. Edit: actually, fcron can run tasks that were supposed to be run when the computer was in sleep mode, but it seems to take 15-60 minutes after the computer is awoken before they are executed. One potential workaround would be to run rtcsleep to make the computer awake during a specific period, run all jobs during that time, and then during that time make fcron run rtcsleep as root to make it re-awake the next time jobs need to be run. Also, I think if the computer is a laptop, the laptop must be left open when the tasks are supposed to run in order for it to not go to sleep again immediately when rtcsleep wakes it. Would this work and is there an easier way? |
Check at and cron daemon.
|
Quote:
|
Quote:
Not sure what you're asking for, but both cron and at will most CERTAINLY run a job on a specific date/time, if the system is up. If you mean something like "I scheduled the job for 8 AM on the first, but the system was down then, and I WANT it to run when the system comes back up", that's a job for your script. Turn your script into a daemon: http://blog.terminal.com/using-daemo...your-programs/ ..and have it check the date/time upon execution. If the system is down at 8 am, and reboots at 9, the script will run, and see it's AFTER the runtime...and you can then make it execute, then go back to sleep and/or reschedule itself to run again/do whatever. There are ways around this, and that's only one. |
I don't know of an easier way except for leaving the computer running. I don't know of any way to trigger something specific without a clock or timer running.
|
This is why there's software as a service. Let someone else run your computer and they keep it always up. You might ask microsoft, by default windows 8 would boot at 3am and do stuff, even when the computer was turned off. But there's no way to guarantee that as the computer could be unplugged. Or unbootable after a windows update. Or it could be running linux. I suppose systemd will have a solution for this sooner or later.
Even if cron or at could do it, the admin can turn off said things. I do. The last thing I want is a process starting in the middle of a boss fight and degrading performance plus upping the latency. |
Quote:
I could turn it into a daemon, but that comes with the potential for memory leaks and the daemon getting killed, so I suspect there is an easier way. |
Quote:
There are a TON of ways to do this:
|
Quote:
And I don't think daemons would be more likely to get killed; I just heard that the ability for daemons to restart themselves is unreliable. Quote:
But I think I will use some variation of the first option. Would it be okay to make it call at to execute itself in the future to keep it running? |
Quote:
Quote:
Quote:
|
All times are GMT -5. The time now is 02:23 AM. |