-1

After running:

sudo chkconfig --add X
sudo chkconfig X on

I ran chkconfig --list X:

$ chkconfig --list X
X           0:off   1:off   2:on    3:on    4:on    5:on    6:off

My understanding is that, after kill -9-ing it, the service will restart.

However, after running kill -9 $PID where $PID is the PID of the service's process, it did not restart.

In other words, running ps -ef | grep X returned only the grep result.

How can I use chkconfig to ensure that, after my service crashes, it will restart?

Kevin Meredith
  • 1,269
  • 2
  • 15
  • 21
  • 3
    What makes you think that your process should magically restart after you kill it? – EEAA Jul 27 '16 at 21:15
  • Per `step 4`, "Set it to autostart " in http://www.abhigupta.com/2010/06/how-to-auto-start-services-on-boot-in-centos-redhat/ – Kevin Meredith Jul 27 '16 at 21:20
  • 2
    Right, autostart **on boot**. That's what chkconfig controls, which processes get started on boot. – EEAA Jul 27 '16 at 21:21

3 Answers3

3

That isn't chkconfig's job.. Try monit or the like.

Tim Brigham
  • 15,545
  • 10
  • 75
  • 115
2

ckconfig does not actually stop or start anything. As the manual explains:

chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories. ...

That's it.

On RHEL 6 init and Upstart are what actually start and stop certain jobs on boot, shutdown or on changing runlevels according to how that /etc/rc[0-6].d directory hierarchy is set up.

You can use Upstart to control startup of services and restart for if and when they fail by using the respawn keyword in an init conf file.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
0

/etc/inittab can be used to force restarting a service if it's using a SystemV style init script, if we're talking RHEL >=6.2 Upstart is available too and you can just add a respawn line to the service's definition file in /etc/init. See DigitalOcean's tutorial for details.

Or think about upgrading/reinstalling to RHEL7.

Systemd supports automatically restarting services on crashes.

Run systemctl edit foo.service

[Service]
Restart=on-failure
fuero
  • 9,591
  • 1
  • 35
  • 40