简体   繁体   中英

Python script start on boot

I'm making a simple python script to run as an executable that runs in the background. Is there a way to make it run on startup? I know that I could add the executable to the Startup directory but that would require me to hard code it according to my machine. I would like it to work on other machines as well (windows and ubuntu). How would I approach this issue? Thanks!

In Linux you can add it to your cron: crontab -e

@reboot python /home/user/myscript.py

(@reboot is for reboots and startups)

In Windows you can use the Task Scheduler and define the "triggered by" as Startup. See the red box for "Create basic task".

In the Program/script field, you should enter:

C:\Python27\python.exe

And in the add arguments, you should enter:

"C:\My script.py"

Read here for more details and see screenshots below...

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM