Running scripts at startup

Posted by on November 1, 2011 in Operating Systems, Ubuntu | 0 comments

If you want to run a command or a script you wrote and have it run in the background every time Ubuntu starts, then simply add the script to the rc.local file. Make sure your script is executable, and then simply insert the full path of the script into the rc.local file. The rc.local file is in the /etc/ directory for Centos and in /etc/init.d/ for Ubuntu.

If you want to reload the rc.local startup file, without restarting your computer, simply do it as you would execute any other script. Note that this will not shut off any processes that are already running, it will execute all the commands just as it would at startup. If you have something that gives console output it will start displaying on your screen, but you can CTRL+C to get out of it, and all the scripts will continue to run in the background. The good thing about that is that your script will continue to run even after you log out of ssh, unlike if you just normally ran your script, it would cease execution when you logged out.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>