There are alternatives way, to set an script on startup. Here are some example’s.
You will need root privileges for any the following. To get root, open a terminal and run the command.
The command prompt will change to ‘#’ indicating that the terminal session has root privileges.
Shell
1 | sander@linuxsource.nl#: <strong>su - root</strong> |
#1 – Add an initscript.
Create a new script in /etc/init.d/linuxsource-script.sh
Shell
1 2 | vi /etc/init.d/linuxsource-script.sh |
(Obviously it doesn’t have to be called “myscript”.) In this script, do whatever you want to do. Perhaps just run the script you mentioned.
Shell
1 2 3 | #!/bin/sh /path/to/your/linuxsource-script.sh |
Make it executable.
Shell
1 2 | chmod ugo+x /etc/init.d/linuxsource-script.sh |
Configure the init system to run this script at startup.
Shell
1 | update-rc.d linuxsource-script defaults |
#2 – Add commands to /etc/rc.local
Shell
1 2 | vi /etc/rc.local |
with content like the following.
Shell
1 2 3 4 | # This script is executed at the end of each multiuser runlevel /path/to/your/linuxsource-script.sh || exit 1 # Added by me exit 0 |
#3 – Add an Upstart job.
Create /etc/init/your-job.conf
Shell
1 2 | vi /etc/init/your-job.conf |
Shell
1 2 3 4 5 | description "my job" start on startup task exec /path/to/your/linuxsource-script.sh |