Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've a MapServer logfile; it is created in /tmp/mapserv.log, but obviously it is flushed at every reboot, and is created only when a loggable event occurs.

I'm already using Multitail, but now I need to watch the folder /tmp for a file that has not even been created, waiting for it to appear.

Any hint?

share|improve this question
    
Could you touch it before starting multitail? (Edited Q) –  Sukminder Apr 18 '13 at 10:43
    
Of course I could write a script or Bash alias to touch it before starting multitail, although I've never tried to run MapServer with an already present logfile (it should append results to it); I'm searching for a more "clean" solution or a specific multitail feature, but, yes. –  fradeve Apr 18 '13 at 10:56

1 Answer 1

up vote 2 down vote accepted

You could perhaps use the -iw option. It check for new files matching a given pattern at a given interval. When one is found start following it.

E.g.:

multitail -iw /tmp/mapserv.log 2

Would look for the file /tmp/mapserv.log every 2 seconds. If and when it appears follow it.

It is meant to take a wildcard as in

-iw "/tmp/map*" 2 
# Quotes needed to prevent the shell to expand the pattern.

but works for non-wildcard as well. The number is how often to check for new files matching the pattern.


Else, touch could perhaps work. Might require something like su user -c 'touch ...' or a chown etc after touch.

If MapServer deletes existing mapserv.log on first logging and not truncate or append you would perhaps also need the -f option, as in:

Follow the following filename, not the descriptor.

share|improve this answer

Your Answer

 
discard

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.