Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split log file monthly

Status
Not open for further replies.

we2aresame

Technical User
Feb 10, 2003
128
CA
Hi, all,
I want to split a log file by monthly which increased every day. The split log file name should like "abc.log.Jun,abc.log.Jul". I know I can use crontab to run a scritp monthly to do so, but anyone can till me how to write the script to achieve my target, thanks in advanced.
 
What generates your log file?
you may use this in whatever produces your log file
date +%m
include this value in your file name as suffix.
e.g.

if [ ! -f abc.log.`date +%m` ]; then
> abc.log.`date +%m`
fi

(command generating log file) >> abc.log.`date +%m`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top