ABillS log rotation

Since some ABillS log files gradually increased in size, I wrote a script to rotate these logs.

Let’s create a log rotation configuration file:

nano /etc/logrotate.d/abills

Here’s an example script:

/usr/abills/var/log/event_asterisk.log {
    daily
    rotate 1
    compress
    delaycompress
    missingok
    notifempty
    create 0666 www-data root
}

/usr/abills/var/log/extreceipt.log {
    daily
    rotate 2
    compress
    delaycompress
    missingok
    notifempty
    create 0644 www-data www-data
}

/usr/abills/var/log/sql_errors {
    weekly
    rotate 3
    compress
    delaycompress
    missingok
    notifempty
    create 0777 www-data root
}

Since the files had different rights and owners, I specified them for each file separately.
For some files, rotation may not be required, for example, the paysys_check.log payment history, you can manually make a copy of this file for the archive, and clear the current one, for example, in this way:

cd /usr/abills/var/log/
ls
echo "" > paysys_check.log

Leave a comment

Leave a Reply