找到 Linux 后台程序的打印输出

最近才狠命的折腾数码日购入的一个  DS920+ NAS,在上面用计划任务来同步两个目录的文件,似乎是在登陆它的 SSH 后的 rsync 同步命令与放在计划任务里的执行效果不一样。于是想看看计划任务里的 rsync -av --delete folder1 folder 时的控制台输出。到哪里去找呢?登陆到 SSH 于只能用 ps 命令看到它的进程 ID

yanbin@nas:~$ ps -ef|grep rsync
SynoRsy+ 10270 1 0 Sep28 ? 00:00:00 /usr/bin/rsync --daemon
root 14067 14066 51 23:03 ? 00:00:02 rsync -av folder1/ folder2/
root 14076 14067 0 23:03 ? 00:00:00 rsync -av folder1/ folder2/
root 14077 14076 58 23:03 ? 00:00:02 rsync -av folder1/ folder2/
Google 了一下找到了这篇 See the STDOUT redirect of a running process, 关键就是用 ls -l /proc/<pid>/fd 列出进程所有打开的文件描述符

阅读全文 >>