Linux下python脚本自启动和定时启动

一、服务器开机自动运行

  1. 用root权限编辑以下文件 sudo vim /etc/rc.local 
  2. 编辑启动脚本的命令地址 /usr/bin/python3 /path/to/python > /path/to/log 

二、定时启动

  1. 编辑crontab文件 crontab -e 
  2. 编辑命令 */30 * * * * /usr/bin/python3 /path/to/python >> /path/to/log 2>&1 
posted @ 2023-07-12 11:14  徐钏  阅读(275)  评论(0)    收藏  举报