mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/package/base/sysklogd/logrotate.cron
  11. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. echo "Logfile sizes (/var/log only): "
  25. for filename in `find /var/log -type f ! -name '*.gz'` ; do
  26. kilobytes=`du -k $filename | cut -f1`
  27. if [ $kilobytes -gt 4096 ] ; then
  28. echo -e "$kilobytes\t$filename\t(rotate, sending sighup)"
  29. for num in `seq 3 -1 1` ; do
  30. [ -f "$filename-$num.gz" ] && mv "$filename-$num.gz" "$filename-$(( $num + 1 )).gz"
  31. done
  32. read mode uid gid < <( stat -c "%a %u %g" "$filename" )
  33. mv "$filename" "$filename-1" ; fuser -s -k -HUP "$filename-1"
  34. sleep 5 ; gzip "$filename-1"
  35. touch "$filename"
  36. chmod $mode "$filename"
  37. chown $uid:$gid "$filename"
  38. else
  39. echo -e "$kilobytes\t$filename\t(don't rotate, less than 4 MB)"
  40. fi
  41. done 2>&1 | expand -t6,45
  42. echo