| 1 | #!/bin/sh |
| 2 | # |
| 3 | # /usr/sbin/rotatelog: rotate logfile |
| 4 | # |
| 5 | |
| 6 | if [ "$1" = "" ]; then |
| 7 | echo "usage : `basename $0` <logfile>" |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | if [ ! -f /var/log/$1 ]; then |
| 12 | echo "`basename $0`: /var/log/$1 not found" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | [ -f /var/log/old/$1.9 ] && rm /var/log/old/$1.9 |
| 17 | [ -f /var/log/old/$1.8 ] && mv /var/log/old/$1.8 /var/log/old/$1.9 |
| 18 | [ -f /var/log/old/$1.7 ] && mv /var/log/old/$1.7 /var/log/old/$1.8 |
| 19 | [ -f /var/log/old/$1.6 ] && mv /var/log/old/$1.6 /var/log/old/$1.7 |
| 20 | [ -f /var/log/old/$1.5 ] && mv /var/log/old/$1.5 /var/log/old/$1.6 |
| 21 | [ -f /var/log/old/$1.4 ] && mv /var/log/old/$1.4 /var/log/old/$1.5 |
| 22 | [ -f /var/log/old/$1.3 ] && mv /var/log/old/$1.3 /var/log/old/$1.4 |
| 23 | [ -f /var/log/old/$1.2 ] && mv /var/log/old/$1.2 /var/log/old/$1.3 |
| 24 | [ -f /var/log/old/$1.1 ] && mv /var/log/old/$1.1 /var/log/old/$1.2 |
| 25 | [ -f /var/log/$1 ] && (cp /var/log/$1 /var/log/old/$1.1; echo -n "" > /var/log/$1) |
| 26 | |
| 27 | # End of file |