Skip to main content

Add Cron Job to backup the server log for custom websites

Some time we want to configure the log for every website in a specifc folder here is how to add a cronjon for the last 10 days

 

37 3 * * * /usr/sbin/logrotate -f -s /var/www/share/etc/logrotate/{website_name}.status /var/www/share/etc/logrotate/{website_name}.conf

where {website_name} any name you want 

now what is the content of the {website_name}.conf

here is an example 

/var/www/share/{example.com}/htdocs/var/log/*.log {
    daily
    dateext
    dateformat -%Y_%m_%d
    missingok
    rotate 10
    noolddir
    compress
    ifempty
    copytruncate
    create 664 web-user web-user
}

 

hope this will help you