Run terminal command (python command) at start up [duplicate]

New to Ubuntu, but have looked everywhere to get this question answered. Found no solution so far. Basically I need to run two terminal commands on startup, which follow each other directly. This will allow me to open a python script on start up. The script works when opened manually, but I'm at a loss to get it to work on boot. In terminal I type:

cd /directory/with/python/script/
python name.py

The script works, but I'm having trouble getting it to run on boot.


Assuming you wish to run this script every time your machine boots, a convenient way is to add an upstart init task.

Create a file my-startup-script.conf (its name is up to you, but it must have extension .conf) in /etc/init, containing the following:

description "Describe what the script does."
start on filesystem
task
script
    cd /path/to/script
    python name.py
end script

Note that your script will run with root privileges.