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.
with content like the following:
# This script is executed at the end of each multiuser runlevel /path/to/my/script.sh || exit 1 # Added by me exit 0
with content like the following
description "my job" start on startup task exec /path/to/my/script.sh
Create a new script in
(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.
chmod ugo+x /etc/init.d/myscript
Configure the init system to run this script at startup.
update-rc.d myscript defaults
You don't need root, or to even login.
You can edit your crontab (
crontab -e) and create an entry like this:
This way, you can run it as a regular user.
@reboot just means it's run when the computer starts up (not necessarily just when it's rebooted).
Comment value and add to file:
[Desktop Entry] Type=Application Exec=/full/link/to/your/newshell.sh Name=newshell Comment=whatever you want
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
nano /etc/init.d/rc.local as follows:
/path/to/my/script.sh || exit 1 exit 0