find -ctime -1 finds all my files, not only the recently changed ones

111 Views Asked by At

I need to check a directory and subfolders every hour, but only for new files.

So i wrote a script with these contents:

#!/bin/bash

find /var/www/html/files/ -ctime -1 |
clamscan -r --remove --log=/var/log/clam/clamscan.log

But for a reason, it doesn't check only the new files, it checks every file (about 6000).

The funny thing is, when I'm for example in the /tmp/ folder and I run find -ctime -1 | clamscan it works.

So I guess I'm missing something but I can't think of what it is.

1

There are 1 best solutions below

1
On

It appears that /tmp supports ctime but /var/www/html/files is apparently on a different file system which doesn't.

Lack of ctime support is relatively common for various reasons; probably try with -mtime instead, or refactor to keep track of which files existed in the previous iteration (or perhaps switch to inotify or similar) if you really absolutely have to watch for new files.