/usr/bin/find: Argument list too long.

I have a bunch of cameras that upload shots via FTP when motion is detected. I've a simple script to manage those files. Generally, I want them moved on daily basis and eventually deleted. However, sometimes there are too many files and I get mail from cron with error message: /usr/bin/find: Argument list too long. The line from script is below, any ideas how to work around it?
Code:
/usr/bin/find $PDIR/front/* -mtime +1h1m -exec mv {} $PDIR/yesterday/front \;
 
Speedy said:
I have a bunch of cameras that upload shots via FTP when motion is detected. I've a simple script to manage those files. Generally, I want them moved on daily basis and eventually deleted. However, sometimes there are too many files and I get mail from cron with error message: /usr/bin/find: Argument list too long. The line from script is below, any ideas how to work around it?
Code:
/usr/bin/find $PDIR/front/* -mtime +1h1m -exec mv {} $PDIR/yesterday/front \;

The first parameter to find(1) is the directory to search. With that star, the shell is going to expand that to every file in that directory. So, based on a cursory, millimeter-deep examination of the code, I'd say lose the star.
 
Yup. The star (*) is redundant anyway. (Unless you're specifically trying to avoid traversing hidden files/directories under that path.)
 
Thanks for replies.

Code:
/usr/bin/find $PDIR/front/ -type f -mtime +1h1m -exec mv {} $PDIR/yesterday/front \;

This seems to work.
 
Back
Top