Linux – Watch a folder and run a command when a file exists

debianlinux

On Debian Squeeze, I'd like for ctorrent to automatically open in a screen session if a new torrent file is placed in a particular folder (/home/torrent). Is there an easy way to, in a script, watch for new files being added to a folder and react to this change?

Best Answer

  • You should check out inotify-wait, that’s exactly what you need:

    https://github.com/rvoicilas/inotify-tools/wiki

  • Related Question