1

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.

A J
  • 11,367
  • 17
  • 44
  • 59
  • 2
    Any reason why you can't run python /directory/with/python/script/name.py directly? – muru Aug 26 '14 at 06:55

1 Answers1

2

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.

zwets
  • 12,354