I'm interested in a replacement for cron which would allow me to run various cron jobs on demand, and mark them as having been run, so they won't be run again from the schedule. Looking through the Fedora repository, I noticed whenjobs, which looks like it may do the job (no pun intended). The documentation for whenjobs says that it is obsolete and has been replaced by goaljobs.
Has anyone tried out whenjobs or goaljobs. Any problems? Will they do what I need done?
Thanks - jon
On Tue, Dec 17, 2013 at 7:23 PM, Jonathan Ryshpan jonrysh@pacbell.netwrote:
I'm interested in a replacement for cron which would allow me to run various cron jobs on demand, and mark them as having been run, so they won't be run again from the schedule. Looking through the Fedora repository, I noticed whenjobs, which looks like it may do the job (no pun intended). The documentation for whenjobs says that it is obsolete and has been replaced by goaljobs.
Has anyone tried out whenjobs or goaljobs. Any problems? Will they do what I need done?
Is there some reason 'at' won't do what you want?
poc
On Wed, 2013-12-18 at 00:52 +0000, Patrick O'Callaghan wrote:
On Tue, Dec 17, 2013 at 7:23 PM, Jonathan Ryshpan jonrysh@pacbell.net wrote:
I'm interested in a replacement for cron which would allow me to run various cron jobs on demand, and mark them as having been run, so they won't be run again from the schedule. Looking through the Fedora repository, I noticed whenjobs, which looks like it may do the job (no pun intended). The documentation for whenjobs says that it is obsolete and has been replaced by goaljobs. Has anyone tried out whenjobs or goaljobs. Any problems? Will they do what I need done?Is there some reason 'at' won't do what you want?
I don't think at will do the job.
In more detail: I have a cron job which backs up my desktop system every day. The job is actually invoked by anacron, which starts it about an hour after I boot up the system for the day. Backing up takes from half an hour to an hour and a half, depending.
* Frequently, I start the system, check my email and leave for breakfast; on these days, I'd like backup to start when I leave; I would invoke it by a shell script or whatever. * Other days, I stay on the system for a while; on these days I'd like cron to start the job whenever its algorithms think best. * I don't want to leave starting the job completely to a shell script run from a terminal, because I'd often forget to run it.
If I can replace cron with at and get the desired result, I'll be happy.
Thanks - jon
On 12/18/2013 12:43 AM, Jonathan Ryshpan wrote:
If I can replace /cron/ with /at/ and get the desired result, I'll be happy.
You may want to consider using batch instead, running the command as part of setting up your login session. This will start the backup when the load average drops below a certain specified value, presumably when you're away from your computer.
Jonathan Ryshpan jonrysh@pacbell.net writes:
In more detail: I have a cron job which backs up my desktop system every day. The job is actually invoked by anacron, which starts it about an hour after I boot up the system for the day. Backing up takes from half an hour to an hour and a half, depending.
Frequently, I start the system, check my email and leave for breakfast; on these days, I'd like backup to start when I leave; I would invoke it by a shell script or whatever.
Other days, I stay on the system for a while; on these days I'd like cron to start the job whenever its algorithms think best.
I don't want to leave starting the job completely to a shell script run from a terminal, because I'd often forget to run it.
Why not run /etc/cron.hourly/0anacron just before leaving for breakfast (or give it an easier to remember alias like "run-anacron-now")?
What I do here the systems that are booted infrequently is add this to /etc/crontab:
@reboot root /etc/cron.hourly/0anacron
and change /etc/anacrontab:
# the maximal random delay added to the base delay of the jobs RANDOM_DELAY=2 # the jobs will be started during the following hours only START_HOURS_RANGE=0-24
-wolfgang
On 18Dec2013 00:43, Jonathan Ryshpan jonrysh@pacbell.net wrote:
* Frequently, I start the system, check my email and leave for breakfast; on these days, I'd like backup to start when I leave; I would invoke it by a shell script or whatever. * Other days, I stay on the system for a while; on these days I'd like cron to start the job whenever its algorithms think best. * I don't want to leave starting the job completely to a shell script run from a terminal, because I'd often forget to run it.If I can replace cron with at and get the desired result, I'll be happy.
Cron's algorithms are pretty simple; the do things when you tell them to:-(
If it were me I'd be doing this as follows:
I have a "flag" command:
https://bitbucket.org/cameron_simpson/css/src/tip/bin/flag
I'd have a cron job for midnight that sets "BACKUP_DUE" to 1:
flag BACKUP_DUE 1
I'd have a core script that runs the backup with not checks of controls. I presume you have such.
I'd have a wrapper script that takes a lock, checks BACKUP_DUE. If false, do nothing, maybe report "backup not due". If true, set it to false and dispatch the core script. Release lock.
Untested hack:
if mkdir /tmp/backup_lock then if flag BACKUP_DUE then flag BACKUP_DUE 0 core_backup_script 2>&1 | mail the-sysadmin & fi rmdir /tmp/backup_lock fi
Have a cron job that fires at 10am or whenever that is fallback for your manual backup dispatch.
Just an idea,