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?
|
I have a script in a folder:
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? |
|||||
|
|
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
|
|
|||
|
|
It is possible to do the same thing by writing a short Upstart job. Initscripts are still supported, however, and are easy to use.
– jdthood
Dec 12 '12 at 15:50
|
||
|
|||
|
|
|||
|
|
Ubuntu 16.04 now uses systemd. As per askubuntu.com/questions/765120/… one can use
sudo systemctl enable rc-local.service to get /etc/rc.local compatibility or see unix.stackexchange.com/questions/47695/… for systemd native script (but /etc/rc.local has the benefit of a lot of simplicity). Maybe add "Alternative #4. Add an systemd job" here?
– djb
Sep 12 '16 at 21:07
|
|
You don't need root, or to even login. You can edit your crontab (
This way, you can run it as a regular user. |
|||||||||
|
|
from terminal
or you can do it from GUI:
|
|||||||||
|
|
In your home, you have a file named .bashrc. This file is executed at the opening of your session. Just put something like this at the end of the file:
EDIT: sorry, i didn't answer your question because my solution is executed when a user is logged in... To execute something before the login, you can try rcconf or rc-file: http://www.debianadmin.com/manage-linux-init-or-startup-scripts.html |
|||||||||
|
|
Simply edit rc.local
|
|||
|
|