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!

J. Doe
  • 1
  • Use python3 path/to/file.py instead – doesn't just running it as an autostart application in the settings suffice? – dessert Oct 15 '17 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 '17 at 17:44

2 Answers2

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.

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

amanusk
  • 1,576
  • OK, I'm testing it now. – J. Doe Oct 15 '17 at 18:30
  • yeah it didn't worked out. – J. Doe Oct 15 '17 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 '17 at 18:51
  • I tried but full path of to the file, is not working out for me. – J. Doe Oct 15 '17 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 '17 at 19:05