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.
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 toinotify
or similar) if you really absolutely have to watch for new files.