我使用命令:
nohup <command to run> &
并且它会记录到nohup.out文件,但是这个日志文件可能会变得非常大,所以想知道是否有一种方法可以自动将输出保存到nohup1.out,nohup2.out nohup3.out等nohup .out变得太大了。这一切都没有终止原始命令。
答案 0 :(得分:6)
logrotate(8)
可能是您需要的,可能已经在您的Linux发行版中。在/etc/logrotate.conf中指定大小限制以及所需的旋转次数:
/tmp/output.log {
size 1k
create 700 user user
rotate 4
}
然后运行logrotate /etc/logrotate.conf
我忽略了示例的文件状态位置,因为logrotate
已经由我的系统作为cron作业运行,并且状态文件已经存在(与示例的位置不同)。