I have a script in a folder:
/path/to/my/script.sh
I need this script to run every time the system starts (even if no one logs in to the system). What do I need to do in order to make this happen?
command linescriptsstartup
I have a script in a folder:
/path/to/my/script.sh
I need this script to run every time the system starts (even if no one logs in to the system). What do I need to do in order to make this happen?
Best Answer
You will need root privileges for any the following. To get root, open a terminal and run the command
and the command prompt will change to '#' indicating that the terminal session has root privileges.
Alternative #1: Add commands to
/etc/rc.local
with content like the following:
Alternative #2: Add an Upstart job (for systems older than 15.04) (not recommended)
Create /etc/init/myjob.conf
with content like the following
Official statement from upstart website -> "Project is in maintaince mode only. No new features are being developed and the general advice would be to move over to another minimal init system or systemd."
Alternative #3: Add an init script (obsolete)
Create a new script in
/etc/init.d/myscript
.(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.
Make it executable.
Configure the init system to run this script at startup.