Hi Mike,
Your script to 'logrotate' the files could look like this:
#!/bin/sh
filetest() { if [ -f wireless_stat$1.tar ] ; then mv -f wireless_stat$1.tar wireless_stat$2.tar fi }
cd /<directory where your files are> filetest 4 5 filetest 3 4 filetest 2 3 filetest 1 2
The filetest function takes 2 arguments, being the oldest and one newer file (you can expand this check to as many as you like, but if you want to keep things around forever, this would not be the best way to do it).
To run this thing, put it somewhere and let root's cron take care of things.
Paul
Thanks Paul!
I think I understand the function is to take the oldest which is the first argument
if it exists rename it to the second argument. So it cd's to my file directory and
sees if wireless_stat3.tar it would filetest 3 4 (rename file3.tar to file4.tar) and
2 to 3, 1 to 2. Yes, I was wondering how to keep it from running forever. I see
now by what you have in your script.
Now to put it all together could I do something like this? ------------------------------------------------------------------------------------------------- #! /bin/bash
tar -c -z -f wireless_stat1.tar wireless_stat
something() { if [ -f wireless_stat1.tar ] ; then rm -f wireless_stat; touch wireless_stat; fi }
filetest() { if [ -f wireless_stat$1.tar ] ; then mv -f wireless_stat$1.tar wireless_stat$2.tar fi }
cd /home/mike/tmp filetest 4 5 filetest 3 4 filetest 2 3 filetest 1 2 -----------------------------------------------------------------------------
Mike
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com