strange behaving using find with cmin in script
Morning,
hoping you might be able to help with some strange (to me) behaviour I'm seeing in one of the scripts I use. we have a process that archives off 3 files every 30 mins. My script runs every 30 mins checking for files created in the last 30 mins and scp's them elsewhere. The script generally runs fine, transferring the expected files across, but every evening when it runs at about 11.30, it sends every file in the sub-directories across, and looking at the date/time stamps against the files I've no idea why. the script excerpt is CheckInterval=30 for FileToSend in `find . -type f -cmin -$CheckInterval` do if scp -rp $FileToSend...... ..... done TIA DanishGambit. |
-cmin does not look at file creation time, it looks at the last status change. If you use e.g. SELinux, you might have a security context setting script that runs then. That would be a status change.
Try last modification time, -mmin instead. Also, you do realize your script will break if you have a file with whitespace in the name? If you use Bash, then you might consider Code:
find . -type f -mmin -$CheckInterval -print0 | while read -rd "" FileToSend ; do Code:
while read -rd "" FileToSend ; do |
Hi Nominal Animal,
thanks for the response, I'll change the script to use mmin tonight and see how it goes. Whitespace isn't an issue in this particular instance due to the naming convention used by the file-generating process, but it's something I'll look at incorporating for other scripts, so good tip. Cheers, DanishGambit. |
solved
Morning,
just to confirm that I've tried my script using mmin rather than cmin and that's sorted the issue. Thanks, DG. |
All times are GMT -5. The time now is 09:51 PM. |