How to delete files in slot of 1000 leaving 7 days of history
Hey all,
I want to create a script which can delete the files older than 7 days but in a slot of 1000. As i have millions of file to delete which i need to perform 1000 files in one slot then next 1000 files and so on. The start state should be 7 days before the present date. I tried deleting all the files after 7 days but it has thrown the below error so want to do it in slot of 1000 files. error : /usr/bin/find: arg list too long usage: rm [-fiRr] file ... Please suggest on this. Thanks, Ankit |
xargs is generally a safe way to do this sort of thing, as rm is invoked individually for each file passed to it.
find /path -type f -mtime +7 -print0 | xargs -0 rm http://en.wikipedia.org/wiki/Xargs |
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
Continue here: http://www.linuxquestions.org/questi...-files-924788/ |
All times are GMT -5. The time now is 03:14 AM. |