LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-15-2020, 05:57 AM   #1
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 128

Rep: Reputation: 6
Question 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?
 
Old 10-15-2020, 06:17 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,772

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
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.
 
Old 10-15-2020, 06:39 AM   #3
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 128

Original Poster
Rep: Reputation: 6
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
 
Old 10-15-2020, 06:42 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,772

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
no, that is not true. tail -F means: keep trying (see man page). Additionally tail has no way to know the new pid.
 
Old 10-15-2020, 07:57 AM   #5
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 128

Original Poster
Rep: Reputation: 6
-F is about file specified, not pid
pid is monitored by --pid
 
Old 10-15-2020, 08:05 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,772

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
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).
 
Old 10-15-2020, 08:19 AM   #7
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 128

Original Poster
Rep: Reputation: 6
--pid means: with -f, terminate after process ID, PID dies
It just exists, nothing more
 
Old 10-15-2020, 09:07 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,772

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
In that case you are right, tail utility doesn't work as you expected.
 
1 members found this post helpful.
Old 10-15-2020, 09:49 AM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,717

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Quote:
A program will never do what you wish but what was implemented!
(Sorry...couldn’t resist)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] 'tail -1 *' doesn't work RandomTroll Linux - Software 4 09-10-2019 02:06 AM
tail the output of tail -n 1 raj k yadav Linux - Newbie 5 02-06-2010 11:26 PM
How to make newer "tail" behave like older "tail" rylan76 Linux - Software 4 12-07-2007 04:27 AM
iptables rules doesn't work as expected.. Shioni Linux - Security 4 11-15-2006 01:37 AM
root-tail doesn't work!! q6z4k Linux - Software 3 05-14-2006 11:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration