Creating a script that removes the oldest files on /tmp directory
Hello friends,
I'm trying to configure a script the deletes the file and directories with more than 10 weeks on my /tmp directory, this is what i'm trying to do: Quote:
could you please let me know what can i do to make this more logical? THANKS! |
Hi,
Why would you go through the if when you are using the simplest command in the if? /usr/bin/find /tmp -mtime +70 -type f -name 'faxjob*' -exec rm -f {} \; done! or do something like: Code:
#!/bin/bash |
I would warn on eco's second solution that if the names have spaces they will suffer word splitting in the for loop.
|
Quote:
You could add the following before the for loop to fix that problem: Code:
IFS=$'\n' |
Or use a while loop and forgo the pain :)
|
Quote:
Quote:
|
You might want to take a look at tmpwatch, it fulfils the same purpose. :)
https://fedorahosted.org/tmpwatch/ |
All times are GMT -5. The time now is 12:54 AM. |