0

I use 17.04 and rc.local is gone(I couldn't do it with rc.local anyway).

I just want this two commands to run at the startup;

cd Folder
python3 file.py

That's it. I looked all the similar answers here but I couldn't make it.

Thank you so much!

2
  • Use python3 path/to/file.py instead – doesn't just running it as an autostart application in the settings suffice?
    – dessert
    Oct 15, 2017 at 17:42
  • hey @dessert the thing is rc.local is gone when 17.04 came out. But answer is much appreciated, I will give it a try that way.
    – J. Doe
    Oct 15, 2017 at 17:44

2 Answers 2

0

Not using 17.04, but under 16.04 there is a "Startup and Shutdown" item in "System Settings". There is an "Autostart" item under there that allows you to specify scripts or programs that you want to run at startup.

4
  • I don't use ubuntu with desktop experience, I'm on terminal but thank you for answering :)
    – J. Doe
    Oct 15, 2017 at 17:47
  • 2
    @J.Doe That's information that belongs in your question!
    – dessert
    Oct 15, 2017 at 18:06
  • @J.Doe please add information to your question! Oct 15, 2017 at 18:47
  • Hey @George I kept it as simple as possible. I use ubuntu 17.04 terminal, I want to do something that will execute this two command in the startup.
    – J. Doe
    Oct 15, 2017 at 18:50
0

You can use a cronjob. Edit your cronjobs with crontab -e, and add the script to run
@reboot /home/user/script.sh as an example

It is best to use a full path to your script

5
  • OK, I'm testing it now.
    – J. Doe
    Oct 15, 2017 at 18:30
  • yeah it didn't worked out.
    – J. Doe
    Oct 15, 2017 at 18:51
  • Does the script do what you want when you simply run it from your terminal? You should make sure the script is executable: chmod +x /home/user/script.sh Then try running /home/user/script.sh from the terminal and see if you get the desired result.
    – amanusk
    Oct 15, 2017 at 18:51
  • I tried but full path of to the file, is not working out for me.
    – J. Doe
    Oct 15, 2017 at 18:59
  • This will not work if invoking your script from the command line does not do what you want. Even if you are not in Folder. If you haven't already, add the interpreter you are using at the top of the script. For example #!/usr/bin/python3. Or wherever you have python3. Use chomd +x to make the script executable. Then try running your script. Just /home/usr/script.py without python3 at the beginning. If the script MUST run from the directory Folder, you can try changing it to use full paths as well
    – amanusk
    Oct 15, 2017 at 19:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.