在 CentOS(以及绝大多数 Linux 发行版)里,nohup 本身并不限制日志文件大小。
nohup command > nohup.out 2>&1 &
nohup.out 只是一个普通文件❌ nohup.out 越来越大会怎样?
/ 分区nohup command >> app.log 2>&1 &
配合 logrotate:
/var/log/app.log {
size 100M
rotate 5
compress
missingok
notifempty
}
StandardOutput=append:/var/log/app.log
nohup command 2>&1 | rotatelogs /var/log/app.%Y%m%d.log 86400 &
| 项目 | 限制 |
|---|---|
| nohup 本身 | 无限制 |
| 单文件大小 | 磁盘 / 文件系统 |
| 实际风险 | 磁盘写满 |
如果你愿意,我可以帮你:
直接说你用的 CentOS 版本和场景即可。