Script to delete older files not running .
Hello all,
I have got a script that deletes the files older than 1 day. Code:
find /path/to/files -type f -mtime +1 | xargs rm -f Anything that need to be changed. |
I do mine off ctime, but I guess it depends what you want. I don't bother with xargs for this either, I use -exec.
Does just Code:
find /path/to/files -type f -mtime +1 |
Quote:
Code:
find /path/to/files -type f -mtime +1 -exec rm -f {} \; |
I use the following it works
touch -d "5 days ago" /tmp/OLD find . -name '*' ! -newer /tmp/OLD -type f -print0|xargs -0 rm -rf {} (notes:-print0 will always print the exact filename,can handle space, new line... otherwise file like "ABC DEF.xxx" won't delete) |
None of the find commands are working. I tried both of them before coming here.
|
Try This...It wont disappoint you :
Code:
find /path/to/files* -mtime +5 -exec rm {} \; |
Tried the command with -mtime +1 to delete all the files older than one day. Todays 12th Jan and it should delete files created on 10th Jan. But its not deleting them.
|
Do this:
Find those files first through Code:
find /path/to/files* -mtime +5 Code:
rm -fr I guess the permission being the issue? Do check. |
Permissions are not the issues. I know bit about linux.
I resolved it. I do not know but removing "+" preceding mtime did it for me. I went through man page for find more than couple of time and then just gave it a chance and it deleted all the files created on 10th Jan. |
The key point from the manpage:
Code:
Numeric arguments can be specified as |
Yeah I went through it and felt I should give it a try. But mtime should have worked since I had some files that were older than 1 day. So it should have deleted them with mtime +1
|
All times are GMT -5. The time now is 06:05 AM. |