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

Solution 1:

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

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

Solution 2:

You can write a bash script with the combinations of "ls" and "find" command to determine if the folder has new torrent files. And then run the script periodically with cron.

Alternatively you can use rTorrent or Transmission-cli. Both has the built in feature to watch a directory for torrent files.

Solution 3:

You may want to use incron, from the description:

incron is an "inotify cron" system. It works like the regular cron but is driven by filesystem events instead of time events.