Set script on startup Ubuntu

bash-script

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.

[email protected]#:  su - root

 #1 – Add an initscript.

Create a new script in /etc/init.d/linuxsource-script.sh

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.

#!/bin/sh
/path/to/your/linuxsource-script.sh

Make it executable.

chmod ugo+x /etc/init.d/linuxsource-script.sh

Configure the init system to run this script at startup.

update-rc.d linuxsource-script defaults

 

#2 – Add commands to /etc/rc.local

vi /etc/rc.local

with content like the following.

# 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

vi /etc/init/your-job.conf

With the content like following:

description     "my job"
start on startup
task
exec /path/to/your/linuxsource-script.sh
Leave a Reply

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

Previous Post
search_google

Searching with Google

Next Post

Manage UFW Firewall

Related Posts