This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

shell Scripting query regarding logs

Old posts that have not been replied to for several years.
Locked
B
BBBS

Post by BBBS »

i've written the following (yes it's ugly, but shell scripts ain't my best trick) script, what it does is run on a cron at 1am to gzip and move the old log leaving the current ones obviously (keep logs is on) to another directory. My main question is, can this be done any neater as i think this is rather ugly, it must run on a cron job.
Cheers

#!/bin/sh
/bin/rm -f /home/bot/temp.lst
/bin/rm -f /home/bot/temp2.lst
/bin/rm -f /home/bot/temp3.lst
/bin/ls -1t /home/bot/logs >/home/bot/temp.lst
/bin/fgrep -v gz /home/bot/temp.lst >/home/bot/temp2.lst
/usr/bin/tail --lines=+3 /home/bot/temp2.lst >/home/bot/temp3.lst
/bin/sed -e 's/^(.*)//bin/gzip /home/bot/logs/1/' /home/bot/temp3.lst |/bin/sh
/bin/mv -f /home/bot/logs/*.gz /home/logs/
Locked