1827459 Members
3666 Online
109965 Solutions
New Discussion

Re: script help

 
Ragni Singh
Super Advisor

script help

Hi all, can you please help me write a script to run in the weekly cron job to archive the prior weeks logs. Thanks and points will definitely be assigned.
4 REPLIES 4
Oviwan
Honored Contributor

Re: script help

Hi

add this line to crontab

#crontab -e

0 0 * * 0 cp /path/to/logs/* /path/to/archive

for more information --> man crontab & cp

Regards
Ragni Singh
Super Advisor

Re: script help

Thanks, I will be using the find command like such...

find /home/xx/* -type f -mtime +5 -exec gzip {} \;.

This will locate the remove all files over 5 days old.

This will also touch the current days files so what can I do here so it doesn't touch the most current days file.
Ragni Singh
Super Advisor

Re: script help

okay, more to this. In /var/log/pgsql/*, I would only like to select the *.log files created in the last 7 days and to gzip them into the single archive for the week.

HOw can this be done.
Ragni Singh
Super Advisor

Re: script help

I will re-phrase and submit my question again.