How about this:
cd /some/path/logsThe beauty of this is the embedded execution statements.
for J in `ls *log?$(date +%Y)-*(expr $(date +%m) - 1)-*`; do
ls -lh $J; tar -czf $J.tgz $J; ls -lh $J.tgz; mv $J /dev/shm;
done
Within the backticks, are a pair of executions, one of which nests an execution.
This particular incarnation compresses last months logs. It shows the original size and the compressed size, then moves the file to a holding directory. On a real machine, I'd probably change the middle line to:
tar -czf $J.tgz $J; rm -f $JPop this in a cronjob and run it at "1 2 3 * *".
No comments:
Post a Comment