LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   tail utility doesn't work as expected (https://www.linuxquestions.org/questions/linux-software-2/tail-utility-doesnt-work-as-expected-4175683673/)

sluge 10-15-2020 05:57 AM

tail utility doesn't work as expected
 
Hello,

I start monitoring is process alive using tail utility by
tail -Fn0 --pid=11111 /opt/mylogfile.log

Process with PID 11111 was restarted and now this process has other PID 22222 but I still see that tail continue monitoring for process with PID 11111. Could it be a tail issue? Icheck /proc and failed to find /proc/11111. May be tail just hangs?

pan64 10-15-2020 06:17 AM

that is the expected behavior. tail has no any idea about your activity (=you restarted the process). tail will keep doing what was told (monitoring the given pid) until you stop it.

sluge 10-15-2020 06:39 AM

Restarting process is to send TERM to it and start it again. When process exit tail should exit also because PID 11111 doesn't exist anymore

pan64 10-15-2020 06:42 AM

no, that is not true. tail -F means: keep trying (see man page). Additionally tail has no way to know the new pid.

sluge 10-15-2020 07:57 AM

-F is about file specified, not pid
pid is monitored by --pid

pan64 10-15-2020 08:05 AM

pid is specified by --pid. -F means --follow and --retry. --retry means: keep trying to open a file if it is inaccessible
It is the tail process itself, not the flag which will monitor the given pid and will try it forever (as long as it was not interrupted).

sluge 10-15-2020 08:19 AM

--pid means: with -f, terminate after process ID, PID dies
It just exists, nothing more

pan64 10-15-2020 09:07 AM

In that case you are right, tail utility doesn't work as you expected.

scasey 10-15-2020 09:49 AM

Quote:

A program will never do what you wish but what was implemented!
(Sorry...couldn’t resist) ;)


All times are GMT -5. The time now is 12:22 PM.