How can I configure a service to run at startup
sudo update-rc.d minidlna defaults
This should add the service to the automatic startup system. But if you get:
System start/stop links for /etc/init.d/minidlna already exist.
Do the command
sudo update-rc.d minidlna enable
P.S.: For further detail look at the man page for update-rc.d by typing the command man update-rc.d
To start a daemon at startup:
update-rc.d service_name defaults
To remove:
update-rc.d -f service_name remove
defaults => default run levels 2,3,4 and 5
Example:
update-rc.d tomcat7 defaults
Sometimes you need to run a script on boot process, for example run an iptables config at boot process. So you don’t have to run the script manually every rebooting.
You can run your script on boot process in Ubuntu by adding it to /etc/init.d/rc.local
file. Look the steps below.
Open
/etc/rc.local
file with this command:vim /etc/rc.local
Add your script that you want to run on boot process there, for example:
sh /home/ivan/iptables.sh echo 'Iptable Configured!'
Review the comments included in that file and make sure an exit 0 is at the end.
Save the files. And your script will run on boot process.