Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Aug 02, 2013 4:50 pm 
Offline
Senior Newbie

Joined: Tue Jun 12, 2012 12:35 pm
Posts: 7
On the Virtual Hosts page there is line about having custom logs for your host but they will not be in logrotation by default. The logroatate guide is also helpful, but unconnected to the vhost setup. If anyone see's any errors, please comment.

https://library.linode.com/hosting-website#sph_configuring-name-based-virtual-hosts
https://library.linode.com/linux-tools/utilities/logrotate

Maybe it will help someone.

----------------------

The service logrotate is pretty straight forward. My logs are made by apache so there are some extra stuff that has to be included. This is not realy a script as much as a small directive file. This file is named mycustomfile and it is placed in the /etc/logrotate.d/ folder. I don't think it matters what the name of the file is. It will be added to what logrotate daemon does. The following example assumes you followed the directions on setting up your vhosts in the linode library.


Code:
/home/example_user/public/example.com/log/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root root
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}



Meaning
The opening line shows the location of the logs with a wildcard statement.
weekly - Run Weekly
missingok - If the file isn't there for a sec, don't sweat it.
compress - compress the old files delaycompress - only compress the file after enough time elapses for apache to restart and start seeing the new file.
notifyempty - don't rotate it if it is empty create 640 root root - create the new file with 640 privs and root user and group
sharedscripts - run once for each
the last bit tells the apache service to restart so that it will start using the new log file.
(Everything about the naming of the files and backups should be automatic.)

Testing
You may want to run tests in verbose mode that actually don't run the log rotation. Remove the "d" which is test mode and replace that with a "f." F will FORCE running even if the scrip calls for running on certain days.

Test
Code:
logrotate -vd /etc/logrotate.d/yourcustomdirective

For Real
Code:
logrotate -vf /etc/logrotate.conf/yourcustomdirective


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group