mindlessacts
asked on
Deleting all logs on all servers quickly
Hello I need to delete all log files in my /home/users folder
I need to go down into ever directory and delete all .log files.
Also if I could use rsync to do it so that I can do this on all my servers that would be great (the server directories are different for some users, and completely different on each server box)
How would I do this?
Thanks, Brad
I need to go down into ever directory and delete all .log files.
Also if I could use rsync to do it so that I can do this on all my servers that would be great (the server directories are different for some users, and completely different on each server box)
How would I do this?
Thanks, Brad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What if I wanted to first make a backup of all those log files. And compress it?
I tried: find /home/users -name *.log -exec tar -cz -f logs.tgz{}\;
find: missing argument to `-exec'
However it did not work
Thanks, Brad
I tried: find /home/users -name *.log -exec tar -cz -f logs.tgz{}\;
find: missing argument to `-exec'
However it did not work
Thanks, Brad
the find command works on each file seperately, you would now need something more like this
for file in `find /home/users -name *.log `
do
tar -A backup.tar $file
rm -f $file
done
compress backup.tar
for file in `find /home/users -name *.log `
do
tar -A backup.tar $file
rm -f $file
done
compress backup.tar
or as a two step process
find /home/users -type f -name "*.log" | tar czvf /tmp/logs.tgz
find /home/users -type f -name "*.log" | xargs rm -f
find /home/users -type f -name "*.log" | tar czvf /tmp/logs.tgz
find /home/users -type f -name "*.log" | xargs rm -f
ASKER
I tried:
find /home/user -type f -name "*.log" | tar czvf /home/logs.tgz
and it returned;
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
However there are several .log files in the directory
find /home/user -type f -name "*.log" | tar czvf /home/logs.tgz
and it returned;
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
However there are several .log files in the directory
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent
Thank you very much for all the help.
Thank you very much for all the help.
I don't think you can this with rsync because of all the differences between servers