写了一个 py 想让它在云服务后台运行
网上搜了半天是使用这个命令,但是关闭窗口后进程还是结束了
网上还说 nohup 按任意键回到 shell,再用 exit 退出,但是关闭窗口后进程还是结束了
求大佬指点
求大佬指点
再试试
还是看点 linux 基础吧…
“`
[Unit]
Description=Python Service
After=multi-user.target
[Service]
WorkingDirectory=/path
User=root
Type=idle
ExecStart=/usr/bin/python3 /path/python.py
Restart=always
[Install]
WantedBy=multi-user.target
“`
喜欢折腾的话还可以装 tmux-resurrect 插件。
tmux attach #0?
我有个问题请教,screen 怎么能一行命令创建并执行?每次都得 screen -dmS xxx 进去运行,然后退出。
“`
systemd-run –unit=py-test python3 /absolute/path/test.py
“`
所以要正经部署的话,自己写个 systemd service,就算脚本遇到意外退出了,还可以自动重启