How can I run a script-based tool which will process files continuously downloaded to given directory as they arrive? I'd like to minimize delay (~1 second is OK), script can have own infinite loop.I know a few ways, like:autologin user with .bashrc or .profile calling my scriptfork script from cron, then ignore if it is already runninguse init scripts somehow (I guess it varies between distributions)What method would work best?
How can I start a file-processing daemon?
shell script;files;monitoring;startup;daemon
Assuming your script is to run under Linux, you can use inotifywait from an init script. You will probably want a recursive search through the entire download tree (option -r). Bear in mind that each node to watch can eat up to 1kB of kernel memory.The main advantage of inotify is to prevent a costly polling loop. It triggers an event as soon as a file operation takes place in the watched directory tree and consumes non-noticeable CPU resources otherwise.