- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: tail script help ..
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
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
11-08-2001 08:53 AM
11-08-2001 08:53 AM
tail script help ..
I have a script that does a
tail -f progmon.log | grep ERROR
Tough a remsh. (progmon.log is a log from a 3rd party app). And our surveillance
center is watching this log 18 hours a day. Now I have a cron job that clears out the log every couple of hours. And what happeneds is that when the log clears the the tail will freeze up.And this kicks them out of the menu driven script. Is there another way to do the tail or clear the log so it does not freeze up?
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:00 AM
11-08-2001 09:00 AM
Re: tail script help ..
The thing that first comes to mind to do is:
# cat /dev/null > progmon.log
or
# > progmon.log
(Those 2 commands do the same thing).
But since the tail process has the file open, I don't know if you'd regain the disk space when you empty the file like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:00 AM
11-08-2001 09:00 AM
Re: tail script help ..
What command are you using for clearing the log?? rm is a no-no , since it deletes the
reference to the file (inode).
You can use,
#cp $logfile $logfile.$$
#>logfile
It should work fine.
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:04 AM
11-08-2001 09:04 AM
Re: tail script help ..
cd /var/simp/logs
for FILE in *.log
do
> $FILE
# sleep 2
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:06 AM
11-08-2001 09:06 AM
Re: tail script help ..
If you are clearing the log by removing and recreating the file, then this will certainly fail. Redirect /dev/null into the log file to clear it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:07 AM
11-08-2001 09:07 AM
Re: tail script help ..
I just did a test that is almost exactly like what you are doing, and doing the '> filename' do screw up the tail. I don't understand why, but it does.
Now I'll have to think about this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:11 AM
11-08-2001 09:11 AM
Re: tail script help ..
while true
do
tail -f progmon.log
sleep 10
done
Then change your script which clears the logs to:
cd /var/simp/logs
for FILE in *.log
do
fuser -k $FILE
> $FILE
# sleep 2
done
A bit messy I know, but it should work.
HTH
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:13 AM
11-08-2001 09:13 AM
Re: tail script help ..
Also, have you though of creating a script that first kills the tail -f, then zeros the logfile, then restarts the tail -f (with nohup and &)?
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:14 AM - last edited on 07-07-2022 04:04 AM by Sunitha_Mod
11-08-2001 09:14 AM - last edited on 07-07-2022 04:04 AM by Sunitha_Mod
Re: tail script help ..
Ooops!
Just thought about this a bit more, and this won't work as it will terminate whatever process is writing to the logs. Of course you could still use fuser to determine the processes that have the file open, and then determine which one is the tail -f using ps.
Just goes to show you should think before you open your mouth!
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 09:35 AM
11-08-2001 09:35 AM
Re: tail script help ..
sed 'd' $FILE > $FILE
The 'd' in the sed command (the single quotes are required) tells it to delete all lines of the file.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 10:06 AM
11-08-2001 10:06 AM
Re: tail script help ..
You remember that stuff about traps. This would be an elegant solution to your problem.
Suppose that your cron job that copies /dev/null to your log or however you wish to clear the log first sends a signal to the your tail script process(es); then sleeps a bit to allow the processes to respond; and then clears your log. Your tail script processes would then respond by sleeping a bit and then restarting themselves and don't forget to reassert the trap.
I could code this for you but it's the journey that's important.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2001 06:20 PM
11-08-2001 06:20 PM
Re: tail script help ..
How about running 'tail' in a loop, rather than relying on 'tail -f'?
Maybe something like
while true
do
tail -24
sleep 1
done
Just replace 24 with the number of lines your screen can display.
Cheers,
Deepak.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 06:48 AM
11-09-2001 06:48 AM
Re: tail script help ..
The GNU tail does this perfectly. Can be obtained from:
http://hpux.connect.org.uk/hppd/hpux/Gnu/textutils-2.0.10
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2001 07:40 PM
11-09-2001 07:40 PM
Re: tail script help ..
1. the log file is not 'rm'ed
2. no more than 24 lines (one screenfull) are written per second.
You could increase the number of lines from 24 to anything you're comfortable with, but with larger values the display tends to be a little jerky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2001 11:47 AM
11-10-2001 11:47 AM
Re: tail script help ..
( while :; tail -f $LOG; done ) | grep ...
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 08:32 PM
11-12-2001 08:32 PM
Re: tail script help ..
Just curious..how did you work around this one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2001 07:45 AM
11-13-2001 07:45 AM
Re: tail script help ..
I am still playing with this .. I have had other issues come up that need to be taken care of. I will assign points and post results when I get a chance.
Richard