0

As my disk space is less , i would need to zip and archive the logs in another directory which are older than 30 days.

Can someone please modify the below command to zip the 30 days older files and move it to destination folder.

find . -name 'server.log*' -mtime +30 -exec zip -r /home/user/Logs/ /opt/apps/log {} \;

where server.log is a log file and there will be many logs with datestamp attached like this server.log_290719.
/home/user/Logs is destination folder and /opt/apps/log is source folder.

cmak.fr
  • 8,696
ABD
  • 1
  • 3
    You should look into logrotate. – Jos Jul 29 '19 at 07:21
  • As @Jobs : logrotate does gzip old logs. But it does not move archives. You should run sudo /etc/cron.daily/logrotate then move gz created files. FYI there are some other files taking a lot of space on root partition. Think snap old packages, old kernels and apt cache See https://askubuntu.com/a/1161181/77093 – cmak.fr Jul 29 '19 at 07:41
  • @jos Logrotate doesn't work very well with filenames that aleady have a timestamp in their name, see https://stackoverflow.com/questions/8962477/logrotate-files-with-date-in-the-file-name – PerlDuck Jul 29 '19 at 07:44

0 Answers0