在 Debian(以及其他 Linux 发行版)中,nohup 命令的日志位置取决于你如何使用 nohup。
如果你直接这样运行:
nohup your_command &
那么:
nohup.out
~/nohup.out
(即当前用户的主目录下)
通常更规范的做法是手动重定向输出:
nohup your_command > mylog.log 2>&1 &
此时:
mylog.log 文件中2>&1 表示把错误输出也写进同一个文件# 实时查看
tail -f nohup.out
# 查看最后 100 行
tail -n 100 nohup.out
# 搜索关键字
grep "ERROR" nohup.out
如果你是用的:
systemctl start xxx
那和 nohup 无关,日志在:
journalctl -u xxx.service
| 使用方式 | 日志位置 |
|---|---|
nohup cmd & |
./nohup.out 或 ~/nohup.out |
nohup cmd > log.txt 2>&1 & |
log.txt |
| systemd 服务 | journalctl |
如果你愿意,可以把你运行的 nohup 命令贴出来,我可以帮你确认日志到底在哪。