tail does not exit

Max N. Boyarov m.boyarov at bsd.by
Wed Dec 19 16:06:35 PST 2007


>>>>> "MT" == Mikhail T. writes:

 MT>  Why does not the script below actually ever exit?

 MT>         #!/bin/sh

 MT>         if tail -f /var/log/messages | awk '{print "Exiting"; exit 0}'
 MT>         then
 MT>                 echo Exited
 MT>         else
 MT>                 echo Failed
 MT>         fi

 MT>         exit 0


 MT> Awk exits as advertised, but tail stays around -- even though its
 MT> stdout is closed... Why?

 ---start quote from man 1 tail---

      -f      The -f option causes tail to not stop when end of file is
             reached, but rather to wait for additional data to be appended to
             the input.  The -f option is ignored if the standard input is a
             pipe, but not if it is a FIFO.
 ---end quote---

 try without "-f" option

-- 
Max N. Boyarov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20071220/0ddcfa99/attachment-0001.pgp


More information about the freebsd-questions mailing list