
我用来tail
监视作业的进度,我知道这些作业会将其进度写入磁盘。几乎总是,我知道它们在开始运行之前将创建哪个文件(作业由超级计算机上的调度程序调度)
有没有办法tail
在创建这些文件之前对其进行处理?我想这样做,同时避免竞争条件和/或对作业如何或何时写入磁盘做出假设。
答案1
使用-F
尾部标志(假设您有tail
来自 GNU coreutils 的标志):
tail -F file-that-does-not-exist
从man tail
:
-F same as --follow=name --retry
--retry
keep trying to open a file even when it is or becomes inaccessi‐
ble; useful when following by name, i.e., with --follow=name
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol‐
low=descriptor are equivalent
答案2
如果您的tail
实现没有该--retry
选项,您可能可以自己作弊并创建文件:
$ touch file && tail-f file
根据您对所有权和权限的要求,这可能就足够了。