是否可以实时查看以“at”安排的任务的输出?比如说,我想在训练网络时查看损失函数的值。
答案1
从我在超级用户上的帖子,获取作业的 PID at
,然后你就可以看到at
保存输出的位置:
$ at now
warning: commands will be executed using /bin/sh
at> sleep 10m
at> <EOT>
job 7 at Sat Jan 7 20:18:00 2017
$ pgrep sleep
7582
$ ls -l /proc/7582/fd
total 0
lr-x------ 1 muru muru 64 Jan 7 20:19 0 -> /var/spool/cron/atjobs/a0000701795998 (deleted)
lrwx------ 1 muru muru 64 Jan 7 20:19 1 -> /var/spool/cron/atspool/a0000701795998
lrwx------ 1 muru muru 64 Jan 7 20:19 2 -> /var/spool/cron/atspool/a0000701795998
如您所见,输出已保存到临时文件中,您现在可以检查:
$ sudo tail -f /var/spool/cron/atspool/a0000701795998
Subject: Output from your job 7
To: muru
您需要这样做,sudo
因为包含的目录不是全世界可访问的(至少在 Ubuntu 14.04 上):
$ sudo namei -lx /var/spool/cron/atspool/a0000701795998
f: /var/spool/cron/atspool/a0000701795998
Drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root spool
drwxr-xr-x root root cron
drwxrwx--T daemon daemon atspool
-rw------- muru muru a0000701795998