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


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:

  • Related Question