clarification on find + xargs rm command
hi all
just have a quick question with a cron i am using to clean up the data directory in my mysql dir basically, we have logging setup on our database cos we've had some issues recently, and we wanted to make sure that we caught anything for the time being basically we have a script that renames the log file and flushes the mysql logs and then deletes log files that are older than a certain date (as data is constantly being written, the log files will always be updated) Code:
#/usr/bin/find /var/lib/mysql/ -type f -mtime +3 | /bin/grep -P '(plain_)+([\d])+(\.log)' | xargs /bin/rm -f plain-bin.000001 plain-bin.000002 plain-bin.000003 that are old files and should be deleted just want to make sure that the command above will work and not delete plain.log plain.000004 (eg. current bin log file, modified 1 minute ago) and for clarification, when i run ls -lF instead of rm -f after xargs if there are no results, it shows everything, but if there are no results for rm -f, it won't delete everything? hope that makes sense thanks dave |
If I was you I would never rely on others saying the rm thing will work or not. Why not try it yourself, so that you can be sure it does what you want it to do? Copy the logs with the -a option to preserve the timestamps and owner attributes to another folder where you can play around and let your scripts run on them.
|
oh yeah, cool
i had it running, and it seemed to be fine it's just that when i ran ls i got a fright (cos it listed all the files in the dir) but i'll just copy some test files and test the script on them thx |
All times are GMT -5. The time now is 04:57 PM. |