I'm on Ubuntu 15.04, and logged in as root, but when I run
ps -ef | grep cron | grep -v grep
to make sure the cron daemon is running, I see the -f
option, which means it is running in the foreground and not as as a daemon. I have not changed anything related to cron since setting this up (on DigitalOcean, from their stock 15.04 image). Why would it not run as a daemon?
(And yes I know I should be using systemd
instead. This was meant to be a quick & dirty solution—since cron is so simple and reliable, right!?—until I could get my *.service
files debugged and working.)
Because it is being run by
systemd
, there is no need for it to fork itself into the background as it is not being called by a shell script that waits for it to exit ( after forking itself into the background ).No. It means that it didn't do a useless little fork-and-exit dance when it started up. These little dances are (vain) attempts to dæmonize programs, on the assumption that one is starting up dæmons by logging in to an interactive session and running the programs from the shell. That doesn't actually work reliably and securely, and is the source of war stories over the years from people who attempted to start dæmons that way and were unpleasantly surprised.
cron
is already dæmonized by dint of being run under a service manager. It doesn't have to do anything at all to become a dæmon. And doing so ranges from pointless to actively detrimental to the good operation of the system. So the convention — thanks to a quarter of a century of people wanting this sort of thing for running dæmons under daemontools, runit, IBM's SRC, and so forth — is to employ whatever command line options simply turn these little dances off. Proper service management has no need of them.Further reading
cron
run script. A collection of run scripts.