Automatically Delete Old Log Files on Check Point

bitcoin-chart-analysis

To keep logs only for certain amount of time, you have to configure it manually with a script and run it through cron jobs.

Here’s the script, you may save it as clean_log.sh

#!/bin/bash
/usr/bin/find /opt/CPsuite-R77/fw1/log/*.log* -ctime +60 -print -exec rm -f {} \;

The script above will find files containing “log” that are older than 60 days and remove it.

Now create a cron job:

[Expert@FW1]# crontab -l
#  This file was AUTOMATICALLY GENERATED
#  Generated by /bin/cron_xlate on Sun Mar 27 21:43:17 2016
# 
#  DO NOT EDIT
# 
SHELL=/bin/bash
MAILTO=""
0 3 1 * * /home/admin/clean_log.sh > /home/admin/cronlog/clean.log 2>&1
# mins  hrs     daysinm months  daysinw command

The job above will execute clean_log.sh every 1st of the month at 3 AM and print all output to clean.log.

Hope you find it useful.

 

Share on FacebookShare on Google+Share on LinkedInPin on PinterestTweet about this on TwitterShare on TumblrShare on RedditPrint this pageEmail this to someone

1 Comment

  1. fred says: Reply

    Very useful thanks !

Leave a Reply to fred Cancel reply