当前位置:网站首页>程序后台运行并实时输出日志
程序后台运行并实时输出日志
2022-08-07 23:54:00 【transformer_WSZ】
将程序非挂断放在后台执行,命令如下:
nohup python -u main.py > run.log 2>&1 &
这里是将程序的标准输出和标准错误都重定向到了 run.log 文件中。
需要注意的是,python程序的输出有缓冲,不会立刻写入到日志文件中,使用 -u 参数来解决此问题:
Force the binary I/O layers of stdout and stderr to be unbuffered. stdin is always buffered. The text I/O layer will still be line-buffered.
程序放到后台执行了,每次手动查看日志很麻烦,使用 tail 命令来实时查看日志:
tail -f run.log
参考
边栏推荐
猜你喜欢

MYSQL高级篇----简介介绍

MYSQL高级篇-----索引优化分析

SVG基本图形

Flexible and easy-to-use sql monitoring script part6

Force buckle 206, reverse linked list

ip and userId in awk statistics log--analyze the behavior of users maliciously brushing the interface

继承关系下构造方法的访问特点注意:把this()访问本类其他成员方法也加进去

小程序API的Promise化

有关原码,反码,补码那些事

【云原生--Kubernetes】PV、PVC
随机推荐
Merge two sorted arrays
Projecting Your View Attentively: Monocular Road Scene Layout Estimation via Cross-view Transformati
每周小结(*68):为什么要打架
合并两个有序链表
像素画家KIN作品欣赏
PLC运动控制系列之梯形速度曲线
Flexible and easy-to-use sql monitoring script part6
MYSQL高级篇----简介介绍
阿里云云原生数据湖体系全面解读
章鱼网络进展月报 | 2022.7.1-7.31
小程序API的Promise化
有关原码,反码,补码那些事
继承关系下构造方法的访问特点注意:把this()访问本类其他成员方法也加进去
分布式一致性协议 之 Lease机制
炒股开户有佣金吗?开户安全吗
最小公倍数三种方法(附代码)
Stream did not contain valid UTF-8 ——vs code 中 rust在debug时报错,中文乱码问题
Flush it can open an account?Is it safe to open an account
doc或docx(word)或image类型文件批量转PDF脚本
【PHP库】phpseclib - sftp远程文件操作