简体   繁体   中英

Zip the log file after cron finishes to save disk space - Ubuntu

I have this command to run a cron and create a log file out of it

cd /root/amazon-crawler/ && python batchscript.py >> `date +%Y%m%d%H%M%S`cronlog.log 2>&

Actually I am running this cron twice a day and each log file has 400mb to 700mb size.

As you can see every time a new file is created because I don't want to miss/delete older log files, though I can manually delete files a week older.

Is there any way you can specify to Zip the log file after a cron is finished.

Better still, use logrotate. It can automatically:

  • rename logfiles
  • compress them
  • discard old logfiles

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM