I'm trying to write a simple cronjob that looks in a specific directory, performs a find command to determine if a file has been modified in the last two minutes, and if not, transfer that file to another directory.
I can find the files that need moving without any issues and rsync those files, but when I merge both commands, all files get moved even if they've been changed in the previous 2minutes.
So far, I've tried:
find /tmp/dir/* -cmin +2 | rsync -ogr --chown=user:group --remove-source-files --exclude=".*" /tmp/dir/* /tmp/dir2
As well as:
find /tmp/dir/* -cmin +2 -exec rsync -ogr --chown=user:group --remove-source-files --exclude=".*" {} /tmp/dir2 \;
I'm not sure what's going on, and why the find command which returns the proper files can't be piped or "exec-ed" properly into the rsync command.
Cheers in advance,
IknowImBad