I want to try and run a command which will go through all files of the server and remove anything which contains a certain word (after I determine the name of a bad script).
I first tried:
locate verybadscript
This produced an extremely long list of everywhere the file was contained.
I then ran
rm -rf /directorywhere the script lives (in one example, where the script was the only thing in that directory).
When I went to the directory it was indeed gone, but running the locate command again still listed the same directory again and this causes a lot of confusion and provides no clarity.
I then found the following command
find / \( -name verybadscript -o -name '*.verybadscript' \) -atime +7 -exec rm {} \;
This works well. When i then run locate verubadscript it shows that it has been deleted properly in most accounts, with the exception of files that have been added or used in the last 7 days.
I then tried adjusting this to
find / \( -name verybadscript -o -name '*.verybadscript' \) exec rm {} \;
which further removes a lot of files except for those added that day.
My intention, once I have this adjusted further, is to create a cron which will automatically remove any bad script once or numerous times a day.
My question is: How can then above command be manipulated further so that every files called 'verybadscript' is deleted, even if it has been used or added in the last 10 minutes?
I would have thought that removing -atime +7 - would result in all files being deleted regardless of the time they have spent on the server.
Or else... if anyone has any other ideas, I'd be very grateful if you could provide some advise.



LinkBack URL
About LinkBacks
Reply With Quote





