How to tail -f logfile. if log file is generate every 1 HR.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to tail -f logfile. if log file is generate every 1 HR.?
# 8  
Old 07-09-2013
Does the crontab change what latest.log points to?
# 9  
Old 07-09-2013
latest.log points to new file

Code:
latest.log -> /usr/home/TF/log/CybertonTransaction.20130710-03.log

after crontab run
Code:
latest.log -> /usr/home/TF/log/CybertonTransaction.20130710-04.log

# 10  
Old 07-09-2013
the tail -F process seems to not let go of the file it was already tailing so creating a new link will not work ... you may need to kill the tail process first prior to creating the new link ...

but if you have to do that, it would be much cleaner and much easier to understand if you tailed the latest file identified by its file name (i.e., CybertonTransaction.20130710-04.log) instead of the generic latest.log ...

Code:
kill -9 $(ps -ef | awk '$0 ~ /tail/ {print $2}')   # <-- assumes only 1 process has "tail" string in command line

tail -f "$(ls -t /usr/home/TF/log/ | head -n 1)"

# 11  
Old 07-10-2013
you can simply try this
Code:
file=`"date +/files/CybertonTransaction.%Y%m%d-%H.log"` 
   
/files/   this is your directory 

tail -f $file

try it in a crontab
# 12  
Old 07-11-2013
Quote:
Originally Posted by Just Ice
the tail -F process seems to not let go of the file it was already tailing
It does, I tested it. If it doesn't, -F is broken on your system.

There'd be no point having a 'follow symlinks' option without it, after all... The OS does that perfectly well all by itself.
# 13  
Old 07-11-2013
Quote:
Originally Posted by Corona688
It does, I tested it. If it doesn't, -F is broken on your system.

There'd be no point having a 'follow symlinks' option without it, after all... The OS does that perfectly well all by itself.
@ooilinlove - on the assumption that the second to the last log is not being updated any longer as soon as the latest log is started ... test the lines below in the order listed on the command line and see what happens ...
Code:
ln -sf $last_file latest.log   # <-- change $last_file to actual file name of 2nd to the last log 

tail -F latest.log

ln -sf $latest_file latest.log # <-- change $latest_file to actual file name of latest log; do this 
                               # on a separate terminal window so you see if tail -F is still working

you should not see any movement on the tail -F run after the first symlink and see changes coming through after the second symlink ... if you still do not see anything with tail -F after second the symlink, append a new readable line to the last log (i.e., date >> $last_log) in a separate window and verify that it does not show on the tail -F window ... if the new line does show up, have your sysadmin troubleshoot ... if it does not, post your complete script ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Alternative to tail -n -0 -F for monitoring live log file

Hello, I have been working on script which need to generate an alert based upon live logs. If string is found then an alert mail must triggered. tail -n -0 -F works fine to redirect the each latest line from live logs file to grep a pattern for matching but it seems to be not working on... (7 Replies)
Discussion started by: ketanraut
7 Replies

2. Shell Programming and Scripting

How to process only new line of tail -f command from live log file?

Hi, I want to read a live log file line by line and considering those line which are newly added to file Below code I am using, which read line but as soon as it read new line from log file its starts processing from very first line of file. tail -F /logs/COMMON-ERROR.log | while read... (11 Replies)
Discussion started by: ketanraut
11 Replies

3. Shell Programming and Scripting

How to tail -f multi logfile in 1 shell script.?

Hello, How to tail -f multi logfile from multi path in 1 shell script. File & Path /usr/home/localmode/mode110l/log/logic/number110/digit110_digit110m4_2013050210.txt /usr/home/localmode/mode103l/log/logic/number103/digit103_digit103m4_2013050210.txt... (4 Replies)
Discussion started by: ooilinlove
4 Replies

4. Shell Programming and Scripting

generate logfile in a shell script

Unix Gurus, I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored. I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies

5. Shell Programming and Scripting

how to track a log file of one process and mail that logfile to a group?

Hi Friendz, I have 14 DB load scripts say 1,2,3....14. I want a script to call each script automatically, and after completion of every script, it needs to track the logfile and mail that log file to a group.and again it should run the next script in sequence 1,2,3...14 Please help me,need... (1 Reply)
Discussion started by: shirdi
1 Replies

6. Shell Programming and Scripting

Piping tail to awk to parse a log file

Hello all, I've got what I'm pretty sure is a simple problem, but I just can't seem to work past it. I'm trying to use awk to pretty up a log file, and calculate a percentage. The log file looks like this: # tail strtovrUsage 20090531-18:15:45 RSreq - 24, RSsuc - 24, RSrun - 78, RSerr -... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

7. Shell Programming and Scripting

how to tail a log file..

Hi All.. I have a log file in which all the backup information is stored. Now i have written a script which get the last line in the backup log file.. ssh -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" However i would like to tail the line last... (4 Replies)
Discussion started by: suri.tyson
4 Replies

8. Shell Programming and Scripting

Modify script to generate a log file

I've seen several examples of scripts in thise forum about having a script generate a log file. I have a script that is run from cron and that monitors a file system for a specfic filename(s) and then performs some actions on them. Normally I call this script from another script (which the one... (2 Replies)
Discussion started by: heprox
2 Replies

9. Shell Programming and Scripting

Bash tail monitor log file

Hi there, I have a problem here that involves bash script since I was noob in that field. Recently, I have to monitor data involve in logs so I just run command tail -f for the monitoring. The logs was generate every hour so I need to quickly change my logs every time the new hour hits according... (2 Replies)
Discussion started by: kriezo
2 Replies

10. Shell Programming and Scripting

tail -f a log file redirected into a new window?

Is this possible? I am attempting to display a new xterm window and tail -f the log file within that new window. I am currently working on a solaris 8 machine if that has any different meaning than the other platforms. As you can see, I am a newbie to this forum and to UNIX. Any help would be... (2 Replies)
Discussion started by: douknownam
2 Replies
Login or Register to Ask a Question