pip install schedule
1
1
二、重启任务
这一部分我们将贴出代码,大致逻辑是先检测到我们要重启的程序id,然后kill掉之后,进行重新启动,代码如下:
import os,sys,schedule
import subprocess,time
def restart_frp():
child =subprocessPopen(["pgrep","-f","xxx"],stdout=subprocessPIPE,)
pid=childstdoutread()decode("utf-8")strip()
#print(pid)
if pid!="":
ossystem("kill -9 "+pid)
child2=subprocessPopen("xxx",stdout=subprocessPIPE,shell=True)
print(timestrftime("%Y-%m-%d %H:%M",timelocaltime()))
if __name__ == '__main__':
restart_frp()
scheduleevery()hourdo(restart_frp)
while True:
schedulerun_pending()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
其中的xxx均为你要 *** 作的程序名称
三、bug记录
自己在运行中若遇到如下错误:在这里插入描述
则执行如下 *** 作:
第一步,执行命令
ls -l /bin/sh
1
1
若显示结果为:/bin/sh -> dash,那就执行第二步:
sudo dpkg-reconfigure dash (出现窗口选择no)
1
1
第三步,再次执行命令:
ls -l /bin/sh
1
1
显示为 /bin/sh -> bash后,重新运行程
frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, >
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)