<html><head/><body><html><head></head><body>Semiosis and I have found copytruncate to be a reliable method to use with logrotate.<br><br><div class="gmail_quote">Greg Scott &lt;GregScott@infrasupport.com&gt; wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre style="white-space: pre-wrap; word-wrap:break-word; font-family: sans-serif; margin-top: 0px">Thanks Vijay - <br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">The appropriate mechanism to do log rotation would be to use logrotate command with the <br />config file available at /etc/logrotate.d/glusterfs. This mechanism rotates log files of all glusterfs processes.<br />The log rotate &lt;volname&gt; command will be deprecated in a  future release.</blockquote><br />I wonder how to do this?  If I am following this correctly - there are a bunch of layers to make this happen:<br /><br />First, a facility named anacron runs periodically to handle things such as log file maintenance.  Looking at a file named /etc/anacrontab that drives the whole thing:<br /><br />[root@chicago-fw1 etc]# more /etc/anacrontab<br /># /etc/anacrontab: configuration file for anacron<br /><br /># See anacron(8) and
anacrontab(5) for details.<br /><br />SHELL=/bin/sh<br />PATH=/sbin:/bin:/usr/sbin:/usr/bin<br />MAILTO=root<br /># the maximal random delay added to the base delay of the jobs<br />RANDOM_DELAY=45<br /># the jobs will be started during the following hours only<br />START_HOURS_RANGE=3-22<br /><br />#period in days   delay in minutes   job-identifier   command<br />1       5       cron.daily              nice run-parts /etc/cron.daily<br />7       25      cron.weekly             nice run-parts /etc/cron.weekly<br />@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly<br />[root@chicago-fw1 etc]#<br /><br />So cron.daily probably schedules things to run every day, probably at 5 minutes past midnight.   Cron.weekly and cron.monthly are empty.   Looking at /etc/cron.daily:<br /><br />[root@chicago-fw1 etc]# ls /etc/cron.daily<br />00webalizer  certwatch  logrotate  man-db.cron  mlocate  prelink<br />[root@chicago-fw1 etc]#<br /><br />And the script we care about
must be logrotate.  Looking at that:<br /><br />[root@chicago-fw1 etc]# more /etc/cron.daily/logrotate<br />#!/bin/sh<br /><br />/usr/sbin/logrotate /etc/logrotate.conf<br />EXITVALUE=$?<br />if [ $EXITVALUE != 0 ]; then<br />/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"<br />fi<br />exit 0<br />[root@chicago-fw1 etc]#<br /><br />A file named /etc/logrotate.conf drives it.  Looking at that file:<br /><br />[root@chicago-fw1 etc]# more /etc/logrotate.conf<br /># see "man logrotate" for details<br /># rotate log files weekly<br />weekly<br /><br /># keep 4 weeks worth of backlogs<br />rotate 4<br /><br /># create new (empty) log files after rotating old ones<br />create<br /><br /># use date as a suffix of the rotated file<br />dateext<br /><br /># uncomment this if you want your log files compressed<br />#compress<br /><br /># RPM packages drop log rotation information into this directory<br />include /etc/logrotate.d<br /><br /># no packages own wtmp and
btmp -- we'll rotate them here<br />/var/log/wtmp {<br />monthly<br />create 0664 root utmp<br />minsize 1M<br />rotate 1<br />}<br /><br />/var/log/btmp {<br />missingok<br />monthly<br />create 0600 root utmp<br />rotate 1<br />}<br /><br /># system-specific logs may be also be configured here.<br />[root@chicago-fw1 etc]#<br /><br />The logrotate .conf file has an include for everything in /etc/logrotate.d, so what's in there?<br /><br />[root@chicago-fw1 etc]# ls /etc/logrotate.d<br />chrony      glusterd        httpd        libvirtd       libvirtd.uml  samba  syslog          yum<br />cups        glusterfsd      iptraf-ng    libvirtd.lxc   ppp           squid  vsftpd<br />dracut_log  glusterfs-fuse  iscsiuiolog  libvirtd.qemu  psacct        sssd   wpa_supplicant<br />[root@chicago-fw1 etc]#<br /><br />And the piece that rotates the Gluster logs:<br /><br />[root@chicago-fw1 etc]# more /etc/logrotate.d/glusterd<br />/var/log/glusterfs/*glusterd.vol.log {<br />missingok<br
/>postrotate<br />/bin/kill -HUP `cat /var/run/glusterd.pid 2&gt;/dev/null` 2&gt;/dev/null || true<br />endscript<br />}<br />[root@chicago-fw1 etc]#<br /><br />So the task seems to be editing this file by hand to include the log file for my Gluster volume.  Or better, what about just making a file named &lt;volume&gt; to rotate the log file associated with &lt;volume&gt; named /var/log/glusterfs/&lt;volume&gt;.<br /><br />My volume name is firewall-scripts.  Here is a first shot at it.  Create a file named /etc/logrotate.d/firewall-scripts that looks like this:<br /><br />[root@chicago-fw1 logrotate.d]# more /etc/logrotate.d/firewall-scripts<br />/var/log/glusterfs/firewall-scripts.log<br /><br />There is no way it will be this simple.    It's **never** this simple.  <br /><br />And it's not.<br /><br />[root@chicago-fw1 logrotate.d]# /usr/sbin/logrotate /etc/logrotate.conf<br />error: firewall-scripts:1 missing '{' after log files definition<br />error: found error in file
firewall-scripts, skipping<br />[root@chicago-fw1 logrotate.d]#<br /><br />It looks like you need a section that restarts the process associated with that log file at the end.  Here is where I get a little bit shakey - what process should I  be looking for?  Or should I just edit /etc/logrotate.d/glusterd?<br /><br />Here I go again stumbling blindly down Trial and Error Avenue.  I could really use some guidance here.  <br /><br />- Greg<br /><hr /><br />Gluster-users mailing list<br />Gluster-users@gluster.org<br /><a href="http://supercolony.gluster.org/mailman/listinfo/gluster-users">http://supercolony.gluster.org/mailman/listinfo/gluster-users</a><br /></pre></blockquote></div></body></html></body></html>