No need to install daemontools
, runit
, supervise
, etc. As useful as these tools are, they cover use-cases you generally are not in need of for only cron. What you simply need can be handled at ease with init. Add to /etc/inittab:
cron:2345:respawn:/usr/sbin/crond -n
Make sure crond
supports the -n
option first. This tells it not to fork and to remain in the foreground. ** Be sure to disable crond from the rc scripts **.
/usr/lib/lsb/remove_initd /etc/init.d/crond
If, for some reason, crond outputs to stdout or stderr, you will need to write a wrapper script to deal with that output, and spawn the wrapper script. Keep that script simple:
#!/bin/sh
#crond-wrapper.sh
exec crond -n &>>/var/log/crond
Alternatively, you can modify the existing packaged init.d/crond
script with one that invokes crond -n
within a while loop. But in that case, you have to be clever about saving the pid
for later use by this script.
at
if the command you schedule runs anotherat
itself, but you really really want to fix yourcron
problem instead. – Ulrich Schwarz May 17 '16 at 11:12{}
icon to highlight code, commands and command output. – cas May 18 '16 at 01:38