python 服务日志监控 tail -f
import subprocess
#path & name of log
filename = '/home/eli/codebase/refactor/api-server/log/online-config-development.log'
#shell command to be executed
command = 'tail -f '+filename+' | grep '+'groupcast'
popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print(command)
while True:
#get the content which the grep command get
print(popen.stdout.readline().strip())
执行之后就是打印不出来结果, 但是我直接在shell中输入打印的command就有结果。
python高手帮忙看下问题。
#path & name of log
filename = '/home/eli/codebase/refactor/api-server/log/online-config-development.log'
#shell command to be executed
command = 'tail -f '+filename+' | grep '+'groupcast'
popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print(command)
while True:
#get the content which the grep command get
print(popen.stdout.readline().strip())
执行之后就是打印不出来结果, 但是我直接在shell中输入打印的command就有结果。
python高手帮忙看下问题。
...全文
相关推荐
python实现tail实时查看服务器日志示例
今天小编就为大家分享一篇python实现tail实时查看服务器日志示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
服务器后台训练模型命令[源码]
本文介绍了两种在服务器后台训练模型时防止因连接断开导致训练中断的命令:nohup和screen。使用nohup命令时,可以在训练命令前加nohup,后加&,这样即使连接断开训练也会继续,输出默认保存在nohup.out文件中。此外,还详细解释了nohup python -u test.py > test.log 2>&1 &命令中各参数的作用,如-u代表不启用缓存,2>&1代表错误重定向到标准输出等。最后提到可以使用tail -f xx.log实时查看日志打印情况。
几个好用的Linux命令
几个好用的Linux命令
Python3监控windows,linux系统的CPU、硬盘、内存使用率和各个端口的开启情况详细代码实例
主要介绍了Python3监控windows,linux系统的CPU、硬盘、内存使用率和各个端口的开启情况详细代码实例,需要的朋友可以参考下
查看Yarm任务日志信息.docx
源码直接下载地址: https://pan.quark.cn/s/e5bd45776e93 log_server ========== python 日志服务器,通过tcp接口收集日志信息 用于多进程并发执行的日志收集, 或者跨机器的日志收集 使用twisted 做为日志收集服务器 ========== 在centos 上测试通过,并用于生产环境


