Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use tail to monitor the progress of jobs that I know will write their progress to disk. Almost always, I know which file they will create before they start running (the jobs are dispatched by a scheduler on a supercomputer)

Is there a way to tail these files before they are created? I would like to do so while avoiding race conditions and/or making assumptions about how or when the jobs write to disk.

share|improve this question
up vote 12 down vote accepted

Use the -F flag to tail (assuming you have tail from GNU coreutils):

tail -F file-that-does-not-exist

From man tail:

   -F     same as --follow=name --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
share|improve this answer

If your tail implementation does not have the --retry option, you could probably just cheat and create the file yourself:

$ touch file && tail-f file

Depending on your requirements with respect to ownership and permissions that might be sufficient.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.