Linux: How to write a System V init script to start, stop, and restart my own application or service
System V (abbreviated as SysV) is most widely used across most Linux distributions. But what is System V?
Init is the program on Unix and Linux systems which spawns all other processes. It runs as a daemon and typically has PID 1. It is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab file. The main advantages is flexibility and scalability provided by SysV.
The Runlevels in System V describe certain states. For example:
- Runlevel 0: Halt
- Runlevel 1: Single user mode
- Runlevel 6: Reboot
All System V init scripts are stored in /etc/rc.d/init.d/ or /etc/init.d directory. These scripts are used to control system startup and shutdown