Reputation: 41
I have a script to start and stop my services. My server is based on Linux. How do I automate the process such that when OS is shutdown the stop script runs and when it is starting up, the start script runs?
Upvotes: 0
Views: 39
Reputation: 76376
You should install init script for your program. The standard way is to follow Linux Standards Base section 20 subsections 2-8
The idea is to create a script that will start your application when called with argument start
, stop it when called with argument stop
, restart it when called with argument restart
and make it reload configuration when called with argument reload
. This script should be installed in /etc/init.d
and linked in various /etc/rd.*
directories. The standard describes a comment to put at the beginning of the script and a uitlity to handle the installation.
Please, refer to the documentation; it is to complicated to explain everything in sufficient detail here.
Now that way should be supported by all Linux distribution. But Linux community is currently searching for better init system and there are two new, improved, systems being used:
They provide some better options like ability to restart your application when it fails, but your script will then be specific to the chosen system.
Upvotes: 1