system | start


Running a script at start up


method 1. using init.d:

sudo nano /etc/init.d/myscript

containing something like:

#!/bin/bash

/path/to/my/script.sh

then:

sudo chmod 755 /etc/init.d/myscript

sudo chown root:root /etc/init.d/myscript

sudo update-rc.d myscript defaults


method 2. using crontab:

sudo crontab -e

adding a line like this to it:

@reboot /path/to/script


method 3. using ~/.config/autostart: see this

method 4. using init:
make myscript conf:

sudo nano /etc/init/myscript.conf

(example myscript.conf given below.)

sudo chmod 755 /etc/init/myscript.conf

sudo chown root:root /etc/init/myscript.conf


# myscript - daemon
#
# The daemon component of myscript

description "myscript"
author "myscript.org"

# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn

# When to start the service
start on filesystem

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn
respawn limit 5 30

# Start the process
env uid=root
env gid=root
env umask=007

exec start-stop-daemon -S -c $uid:$gid -k $umask -x /path/to/script -- -d