Linux – Init.d vs Cron – which to use

crondebianinitlinux

I'm writing a silly little script to email people when a (Debian Lenny) server boots. Right now I've set it up as an init.d script using update-rc.d, but then I realized I could have just used cron jobs instead. Is it better to use cron jobs for something like this, or init.d?

I haven't actually tested whether the script runs at boot time but it should work. Haven't tried rebooting yet, but the underlying problem is that we randomly had the server reboot once and just shut down/power down randomly another time, so we're wondering whether it's power failures or something else. This would at least let us know when the server reboots.

Best Answer

Since this sounds like a run-and-be-done script I would say that /etc/rc.local or cron (time: @reboot) is definitely the way to go.

On the other hand, anything which will stay daemonized should definitely has its own init script. If nothing else, to make sure it shuts down properly.

Related Topic