Startup script

When it comes to run a script at Ubuntu/Raspbian startup it may be a pain. Where are some ways of doing it:

  1.  rc.local

    rc.local is one of the last services to start at startup. Scripts executed by rc.local have the advantage of already having the network set up.

    To edit rc.local file, run the following command on a terminal:

    $sudo nano /etc/rc.local
    

    rc.local file will open and at the end of the file add the following line:

    /path/to/script
    

    where /path/to/script is the absolute path to the script it self.

  2. crontab

    Any user may add a script to crontab, not just root.
    crontab is executed before some system daemons or other facilities.  This my lead to not having services like network (Running Services After the Network is up)

    To edit crontab, run the following command on a terminal:

    $crontab -e
    

    crontab file will open and at the end of the file add the following line:

    @reboot /path/to/script
    

    where /path/to/script is the absolute path to the script it self.

  3. init.d

    This script is meant to start and stop services during system initialization and shutdown.
    Check the file /etc/init.d/README for more details.

Advertisements
This entry was posted in Computer Stuff, Raspberry Pi, Ubuntu and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s