NOTE: I am running Red Hat 6.7

I have a service that is configured with the Linux init system to start a process as a service when the machine boots. This was done by doing this one-time configuration from the command line:

ln -snf /home/me/bin/my_service /etc/init.d/my_service
chkconfig --add my_service
chkconfig --level 235 my_service on

When the OS reboots, the service starts as expected.

I ALSO need the service to be restarted if the service (my_service) crashes. From what I've read, all I need to do is add an entry to /etc/inittab that looks like this:


Where my_service_starter looks like:

/home/me/bin/my_service start

The my_service script looks like:

"/usr/java/bin/java" /home/me/bin/my_service.jar start

My understanding is that when the init system detects that my_service is not running, it will attempt to restart it by running "my_service_starter".

However this does not seem to be working. i.e. the service does not start when the OS reboots.

I need to understand how to tell the Linux init system to restart my service when the service crashes.

  • I updated the post to try to clarify things a bit more. "does not seem to be working" means that the service does not start when the OS boots. The my_service script simply runs a java jar file in a jvm (see updated post for details). – StvnBrkdll Sep 9 '16 at 16:08

RedHat 6 uses upstart as the init system.

At the very beginning of the provided inittab files are the lines:

# inittab is only used by upstart for the default runlevel.

You need to create a proper init definition in /etc/init (note: NOT /etc/init.d).

eg (but may need debugging) /etc/init/myservice

start on runlevel [2345]
stop on runlevel [S016]

exec /home/me/bin/my_service_starter
  • after my post I came across the information on RHEL 's Web site indicating RHEL v 6 uses upstart. Your suggested solution works. – StvnBrkdll Sep 9 '16 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.