I've had the displeasure of bitterly realizing that (after a few days) upon rebooting of my system, that init.d scripts written by myself were not executed. This caused a bit of problems, but I think I've fixed it.

So now, I would like write up a script in which I will install to the crontab that will check if the init.d scripts are working or not.

Q: How does one check if init.d scripts are working? Or see a list of the init.d scripts working?

The Idea: Check if the init.d scripts are running, if not, send out an email, to notify myself, that for some reason the init.d script has failed.

  • sysvinit doesn't work like this. Depending on the distro you might be able to do a chkconfig --list <serviceName> to see what run levels it's enabled for but other than that your init script should implement something when it's given status instead of a stop or start so that you can do things like service serviceName status to check to see if it's still running. Ultimately, the person writing the initscript needs to know how to figure out if it's still running.
    – Bratchley
    May 19, 2015 at 1:59
  • The way to preserve sanity here is to leave init scripts to the distro maintainers and simply place all your own boot-up code in /etc/rc.local.
    – Atsby
    May 19, 2015 at 9:02

1 Answer 1


You can't generically tell whether an init script was executed from a cron job. You'd have to look for some side effect of the init script, and cron is pointless for that. Make your init script emit a log message.

If you want to make sure that a service is running, use a monitoring mechanism (possibly network-based if the service is offered over the network). This isn't about whether the init script ran, that's just one fairly unlikely failure mode. It's about making sure that the service is available when needed.

How to execute a script when the system starts depends on which init system is in use. Since there are many alternatives (even on Linux, and sometimes even on the same release of the same distribution), check the documentation of your operating system to see how to make an init script run. Note that with most of them, it isn't enough to drop a shell script in a directory somewhere, you also need to add some control information somewhere (in a configuration file, a symbolic link, as a comment in the script, …).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .