我正在尝试运行 Python 程序以查看屏幕程序是否正在运行。如果是,则程序不应运行其余代码。这就是我所拥有的,但它不起作用:
#!/usr/bin/python
import os
var1 = os.system ('screen -r > /root/screenlog/screen.log')
fd = open("/root/screenlog/screen.log")
content = fd.readline()
while content:
if content == "There is no screen to be resumed.":
os.system ('/etc/init.d/tunnel.sh')
print "The tunnel is now active."
else:
print "The tunnel is running."
fd.close()
我知道这里可能有几件事不需要,还有很多我错过了。我将在 cron 中运行这个程序。