1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#!/bin/ksh
#
# rotate mgetty log files
# (this needs manual adaption of all relevant paths, otherwise it won't work)
#
# run this once per week from crontab
#
# $Log: mvlog,v $
# Revision 1.4 2012/07/18 09:53:42 gert
# do not rotate empty mgetty files (leftover from now-unused ttys)
#
# Revision 1.3 2005/03/13 17:41:32 gert
# change mgetty default logfile name (log.tty -> mgetty.tty)
#
# Revision 1.2 2004/11/13 09:16:48 gert
# faxrunqd pid file lives in FAX_SPOOL_OUT (non-root user)
#
# Revision 1.1 2003/01/19 21:28:10 gert
# mgetty log file rotator (base script)
#
#
# where the "mgetty.$tty" files can be found...
#LOG=/var/log/mgetty
LOG=/var/log
cd $LOG || exit 1
# faxrunqd will rotate its log file itself - tell it to
kill -USR1 `cat /var/spool/fax/outgoing/faxrunqd.pid`
# which ttys are in use here?
TTYS=`ls -l mgetty.tty* | sed -e 's/.* mgetty\.//'`
# rotate mgetty logs
for d in $TTYS
do
# no point in rotating empty files, just erase them
if [ ! -s mgetty.$d ]
then
rm -f mgetty.$d
continue
fi
cd OLD || exit 1
for i in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2
do
im1=$(( $i - 1 ))
test -f mgetty.$d.$im1 &&
mv mgetty.$d.$im1 mgetty.$d.$i
done
cd ..
cp mgetty.$d OLD/mgetty.$d.1
> mgetty.$d
done
cd OLD || exit 1
for i in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2
do
im1=$(( $i - 1 ))
test -f sendfax.$im1 &&
mv sendfax.$im1 sendfax.$i
done
cd ..
cp sendfax.log OLD/sendfax.1
> sendfax.log
|