Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@netkicker:~# cat /etc/cron/monthly/syslog
- #!/bin/sh
- #
- # /etc/cron/weekly/syslog: rotate log files
- #
- /root/sbin/logrotate auth cron debug kernel mail messages net all
- # End of file
- root@netkicker:~# cat ~/sbin/logrotate
- #!/bin/sh
- #
- # logrotate: rotate and compress logfile(s)
- #
- export PATH='/bin:/usr/bin'
- ldir="/var/log"
- [ $# -lt 1 ] && \
- { echo "usage : `basename $0` <file> [<file> ..]" ; exit 1 ; }
- for f in $* ; do
- # skip if does not exists or empty
- [ -s $ldir/$f ] || continue
- # keep up to 9
- for i in {8..0} ; do
- [ -f $ldir/old/$f.$i.xz ] && \
- mv -f $ldir/old/$f.$i.xz $ldir/old/$f.$((1+i)).xz
- done
- cp -p $ldir/$f $ldir/old/$f.$i && \
- : > $ldir/$f && xz $ldir/old/$f.$i
- done
- # End of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement