- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- tail on deleted/re-recreated file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 06:40 PM
09-21-2003 06:40 PM
First, my OS's are HP-UX 10.20 & 11.0
When I use "tail" command to monitor a log file, if that file is deleted and recreated with the same name ( while tail is running ), then "tail" still runs but never show new lines added to the file. As far as I know, that is the normal behaviour.
Anybody knows if exists some sort of utility/command that can "monitor" a file even if it's deleted and recreated with the same name?
Thanks in advance.
Kind regards,
Zigor
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 07:08 PM
09-21-2003 07:08 PM
Re: tail on deleted/re-recreated file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 07:53 PM
09-21-2003 07:53 PM
Re: tail on deleted/re-recreated file
As explained a file is not a file, but an inode. If you want to empty the file to be able to start all over, it's better to null it then to remove and re-create it. Else there is no "tail" solution possible. Of course Perl or other scripts can be written to work around it.
>/path/to/my/file
is an easy way to null a file, the inode remains then so that also tail -f will start working.
Regs David
B.T.W. "cp" will create a new inode where a "mv" on the same FS will keep the inode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 08:17 PM
09-21-2003 08:17 PM
Re: tail on deleted/re-recreated file
Hi Zigor,
I have just tried a workaround, which unfortunately did not work! First, I had a continous tail running on a log file, e.g.:
# tail -fn1 your_log_file
I then appended to that file, e.g.:
# echo "helli" >> your_log_file
# echo "hello" >> your_log_file
to which the continous tail reacted.
I then tried to set the file pointer of your_log_file into zero position:
# cat /dev/null > your_log_file
which truncates the file to zero bytes. Unfortunately the tail command is not aware of this; it still looks at the position it was on before the /dev/null action. Therefore, it is not until you write past the position before the "dev/null" action that the tail command reacts again.
I cannot see how to overcome this, except by creating the log file as a fifo, e.g.:
# mkfifo your_log_file
# tail -1fn your_log_file
# echo "halli hallo" > your_log_file
which of course is not what you want, as it raises a number of other problems, but I am looking forward to the coming suggestions!
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 08:47 PM
09-21-2003 08:47 PM
Re: tail on deleted/re-recreated file
Thanks for the replies.
Forgot to mention that I have not control over the log files, so I can not create, copy or move them.
I think I need some kind of new "tail" binary, that can do some kind of monitoring over the original inode and reopen the original file name in case it has been re-created ... or something like that ;-)
Thanks again for all your replies.
Kind regards,
Zigor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 09:04 PM
09-21-2003 09:04 PM
Re: tail on deleted/re-recreated file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 09:56 PM
09-21-2003 09:56 PM
Re: tail on deleted/re-recreated file
Now it's clear, I'm looking for something impossible, ... or not developed yet ( it could be a good and very useful improvement ).
Anyway, thanks to all.
Kind regards,
Zigor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2004 03:56 AM
01-05-2004 03:56 AM
SolutionThere is a module for Python call TailFollow which addresses this exact problem. Unfortunately HPUX ships with Python 1.something; TailFollow expects 2.0 or later. I was able to downgrade the core component of TailFollow to 1.something capabilities.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2004 04:03 AM
01-05-2004 04:03 AM
Re: tail on deleted/re-recreated file
Another option would be to periodically (once a minute or whatever), make a copy of the log file and diff it to your previous copy and then have your script react that diff instead.
Best regards,
Kent M. Ostby