To monitor a log that gets truncated

##############################


This is how to monitor a log that keeps getting truncated (shrunk when it reaches a certain size). You can roll over its output with nohup & tail to another file (by default it will go to nohup.out in the same folder, but you can always redirect it)

Need to know name of file before hand. If the file doesn’t exist yet, you will need to “touch” it, if the file already exists then just touch it.


If you want to save it to nohup.out

touch truncatelogfile.txt

nohup tail -f truncatelogfile.txt &

tail -f nohup.out


If you want to save it else where:

touch truncatelogfile.txt

nohup tail -f truncatelogfile.txt 2>&1 > /data/nohupped.log &

or (if bash 4+)

nohup tail -f truncatelogfile.txt &> /data/nohupped.log &

Then you can tail -f /data/nohupped.log

Leave a Reply

Your email address will not be published. Required fields are marked *