Go Back   PCMech Forums > Linux Support > Linux OS and Software Assistance

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-24-2002, 03:50 PM   #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 run-parts /etc/cron.hourly'
(if that helps)

Thx guys
Battery Powered is offline   Reply With Quote
Old 08-26-2002, 05:53 PM   #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
obdulio is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:27 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2