Py学习  »  Python

系统启动时自动运行python程序

JOKER • 5 年前 • 1597 次点击  

有没有办法让python程序在系统启动时在后台运行?

(在windows和linux系统上)

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50620
 
1597 次点击  
文章 [ 4 ]  |  最新文章 5 年前
Akash Kumar
Reply   •   1 楼
Akash Kumar    5 年前

这个解决方案是专门针对linux系统的

  • 将脚本放入/etc/rc.local 当系统启动时,那里的脚本作为根运行

将脚本添加为 python /path/to/script.py &

所以加上 python/path/to/script.py& /etc/rc.本地

For More Info Refer this

Sarvesh
Reply   •   2 楼
Sarvesh    5 年前

是的,如果你的操作系统是linux,那么你可以试试supervisor。否则,您可以直接在linux中为您想要运行的python文件创建一个服务,然后在系统启动时将其启用为自动启动。

Exp
Reply   •   3 楼
Exp    5 年前

在终端中的linux上:

crontab -e

然后将以下内容添加到文件中:

@reboot /usr/bin/python3 /path/to/your/python/script.py
Hamza Lachi
Reply   •   4 楼
Hamza Lachi    5 年前

你可以在启动时添加你的脚本!

这是10号窗口的

1)首先打开文件资源管理器!

然后粘贴这个地址 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

这是截图!

enter image description here

在那个文件夹里粘贴你的脚本!

这是另一张截图!

enter image description here

系统启动时它会自动启动脚本

另一件事,你可以尝试任务调度!

更多的细节,这里是网站,可以帮助你!

https://tunecomp.net/add-program-to-startup-windows-10/