INDIA +91 964 309 2571 | USA +1 650 405 4891 info@navyuginfo.com

With reference to ‘https://linux.die.net/man/1/monit’, we can use MONIT for log rotation and as exception notifier from a log file.

Steps are as follows :

Create new file ‘sudo nano /usr/local/bin/rotate’

#/bin/bash /bin/mv $1 $1.`date +%y-%m-%d-%H-%M-%S`

At the end of file ‘sudo nano /etc/monit/monitrc’

check file sidekiq_log_rotate with path #comlplete_path_for_sidekiq.log

if size > 10 MB then

exec "/usr/local/bin/rotate #comlplete_path_for_sidekiq.log"

check file sidekiq_log with path #comlplete_path_for_sidekiq.log

if match "error" then alert

check file prod_log_rotate with path #comlplete_path_for_production.log

if size > 10 MB then

exec "/usr/local/bin/rotate #comlplete_path_for_production.log"

check file prod_log with path #comlplete_path_for_production.log

ignore match "trip_reading_errors"

ignore match "TripReadingError"

if match "[Ee]rror"

then alert

check file cron_log_rotate with path #comlplete_path_for_cron.log

if size > 10 MB then

exec "/usr/local/bin/rotate #comlplete_path_for_cron.log"

check file cron_log with path #comlplete_path_for_cron.log

ignore match "trip_reading_errors"

if match "error"

then alert