Delete files older than 500 days Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Delete files older than 500 days without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have directory with files from 2010 year.. I want to delete all files older than 500 days and I tried this:

find /var/log/arc/* -type f -mtime +500 -delete {};      

But I get this:

-bash: /usr/bin/find: Argument list too long

As I know this means that there are too many files and find can’t handle them. But even if I put +2000 which is 3+ years I still getting this.

What I’m missing here?


You’re missing that find doesn’t need a list of files as input. The problem is that the glob /var/log/arc/* expands to too many files. However, find will recurse into subdirectories by default, so there’s no need to use the glob at all:

find /var/log/arc/ -type f -mtime +500 -delete

-delete is a non-standard predicate. If your find implementation doesn’t support it, you can use:

find /var/log/arc/ -type f -mtime +500 -exec rm -f {} +


We are here to answer your question about Delete files older than 500 days - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji