I use batch to rerun failed cron jobs. I also use it
for webhooks. There are three reasons for doing this
and why eventually I’ll end up changing even first runs of
cronjobs to use batch. They handle load issues, locking
issues and return quickly.
batch command is usually implemented as part of
cron and at, but it runs at a certain load,
not a certain time. It can be set at different loads
when the system is configured, but the idea is that
run jobs one at a time when the system load is “low”.
Note the “one at a time” part. This removes the need for
locking. Suddenly you have a queuing system on your Linux
box w/o having to install lots of stuff. It’s not a super
awesome queuing system, but it’s generally good enough.
It’s certainly good enough that I’ll drop
flock once I switch
all my cronjobs to
batch. Having periodic jobs monitored to
make sure they run every X hours makes the idea workable.
Lastly, there’s the returning quickly. Submitting a batch
job is quick and simple. This is really important for
webhooks but also nice when having to rerun certain longer
running jobs like backups.