linux 使用 nohup 运行 python 脚本,脚本中不要有input

如题

服务器系统由windows换为linux后
阿里云的个人服务器报警性能受限
但是服务器上运行的程序仅有数据采集,windows服务器上运行绰绰有余
按理来说linux上会更轻松才对
检查一番后发现使用nohup运行的python脚本中有input,导致cpu使用率居高不下

运行测试验证一下

运行python脚本

while True:
    try:
        input('输入测试')
    except Exception as e:
        print(e)

linux中使用命令
nohup python nohup输入性能测试.py > /dev/null 2>&1 &

运行后cpu使用率骤升

posted @ 2022-12-30 12:45  meizhengchao  阅读(187)  评论(0编辑  收藏  举报