|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (9 bit)
Join Date: Jan 2002
Location: UK
Posts: 389
|
Shell script & Log file question
I want to rotate some log files ona dailt or weekly basis, wot would be the best way to do this?
I would like the log file to be coppied to logfile_date then wipped clean or the next day Would a shell script be the right way about it? I can do the wiping daily bit of the shell script just not adding the current date to the filename And also, i use a shell script to run something hourly, and hourly i get reports through the root mail account of the program feedback, is there a way to disbale this feedback comming in the mail, The mail is titled 'cron (if that helps) Thx guys |
|
|
|
|
|
#2 |
|
Member (5 bit)
Join Date: Mar 2001
Location: Beautifull Rio de Janeiro
Posts: 26
|
filename=logfile_`date`
mv new_log log_dir/$filename where new_log is the newly created log and log_dir is the directory where you want to store the log. You may run it from the cron. Also you may want to look at the sintax of the date command. There are several ways to format the output of it, find the one that best fits your needs. To delete the logfiles that are older than x days, use find log_dir -mtime +x -exec rm {} \; wher log_dir is the directory where you store the logfiles. Be carefull that this command will search and erase in all subdirectories. HTH |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|