0

I have some python commands that I want to run at startup, what I need to do everytime I boot my machine is manually start them by changing directories and executing them. Is it possible to make an exectable file which will execute a list of commands in the terminal? Or is it possible to let those command run at the startup ? It will be very handy to make those run by a simple double click instead of manually doing that.

  • in your system settings, there should be a setting for declaring programs to run at start – ravery Jul 04 '17 at 17:56
  • Please clarify what commands you need to run, to do what. Furthermore, do they need to run from their directory? Do you need them to run in terminal? Also, It seems you need to run them on log in rather than startup, right? – Jacob Vlijm Jul 04 '17 at 19:36
  • @JacobVlijm the commands I use to run are pythonfiles, which help me run a bot, python3 botname.py What I need to do is, make them run as soon as I'm logged in or as soon as the System boots, maybe I got confused between the two, using the solution ravexina provided, I'm able to add those on startup, but the bot doesn't run the way it should as the wifi isn't turned on, I'm not sure what to do to make it run the way I want. – Schezan Mansuri Jul 04 '17 at 20:57
  • Ah, censorship now too. Excellent. – Lightness Races in Orbit Jul 07 '17 at 17:34

2 Answers2

0

First you need to make the file executable using cmd chmod +x filename.py as your say it is a python file.

After press start button or open Ubuntu dash and search StartUp

Startup Luncher

Click on Add

Menu list in Startup

You will able to see as above now enter name of command and provide path of file, if you want can add some comment. now click on add, your program will run on startup

0

I suggest using rc.local to run your commands at the startup (boot time).

  1. First cd into the commands directory:

    cd /path/to/commands
    
  2. Then make them executable (*.py means all files with the py extension):

    chmod +x *.py
    
    • You can run the command one by one on all files too:

      chmod +x command1 command2 cmd3
      
  3. Open /etc/rc.local file using an editor you like:

    sudo nano /etc/rc.local
    
  4. Addd the commands like:

     ./path/to/commands/command1
     ./path/to/commands/command2
     ...
    
  5. Save the file and make sure rc.local itself is executable:

     test -x /etc/rc.local || sudo chmod +x /etc/rc.local 
    

You are done, in each boot your commands get executed.

Ravexina
  • 55,668
  • 25
  • 164
  • 183