One approach is to add an @reboot cron task:
crontab -ewill allow you to edit your cron.
Adding a line like this to it:
will execute that script once your computer boots up.
Depending on what sort of scripts you need to run.. For services and the like you should use upstart. But for a user script these should be launched as session scripts by gnome! Have a look under System > Preferences > Startup Applications.
On a side note if you need some scripts to be run on terminal login you can add them to the .bash_login file in your home directory.
For 14.04 and older
A simple command (one which doesn’t need to remain running) could use an Upstart job like:
start on startup task exec /path/to/command
Save this in a
.conf file in
/etc/init (if you need it to run as root when the system boots up), or in
~/.config/upstart (if you need it
to run as your user when you log in).
You can add commands to
sudo nano /etc/rc.local
This executes the commands as root.
To execute commands as a specific user, use
sudo -i -u (
-i to also run the login shell). For example, to establish a persistent SSH tunnel, where
myhost is definde in
sudo -i -u johndoe autossh -nNT -L 1234:localhost:1234 myhost
Note that if
/etc/rc.local did not exist (as is the case on Ubuntu since 16.04), you need to add a shebang line at the top (e.g.
#!/bin/bash), and ensure the file is executable:
sudo chmod a+x /etc/rc.local