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.

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
  • 57,256