#698
[Linux] How to automatically start a program after boot
Go to /etc/init.d
Create a startup script called “SCRIPT_NAME” like :
#!/bin/bash # /etc/init.d/SCRIPT_NAME ### BEGIN INIT INFO # Provides: SCRIPT_NAME # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Example initscript # Description: This service is used to manage SCRIPT_NAME ### END INIT INFO case "$1" in start) echo "Starting SCRIPT_NAME" /path/to/SCRIPT_NAME ;; stop) echo "Stopping SCRIPT_NAME" killall SCRIPT_NAME ;; *) echo "Usage: /etc/init.d/SCRIPT_NAME start|stop" exit 1 ;; esac exit 0
Make the script executable
sudo chmod chmod 755 /etc/init.d/SCRIPT_NAME
Add it to the list of script to start :
sudo update-rc.d SCRIPT_NAME defaults
Manual start :
sudo /etc/init.d/SCRIPT_NAME start
Manual Stop :
sudo /etc/init.d/SCRIPT_NAME stop
Comments are currently closed.