Skip to content

How to monitor a folder in background

David Emanuel Santiago edited this page Jan 21, 2020 · 4 revisions

How to monitor a folder in background

This can be easily done with scripts, there's no point in making it part of NewsUP. But since this is a feature that is always being requested, i'm posting an example of how to achieve this. This script is working with NewsUP, but is very easily changed to support other command line clients.

Please also take a look into the page how to share torrents

Installation

Assuming that you have a newsup installation working (that you can invoke newsup on the command line), you can use the following script:

https://gist.github.com/demanuel/ebcc0bd34c13b05fe1b422169a4a593c

To use it:

  1. download it

  2. chmod +x newsup_monitor.sh

  3. ./newsup_monitor.sh -d <folder_that_you_want_to_monitor>

if you want to stop monitoring the folder: ./newsup_monitor.sh -s

Other uploaders

If you don't use newsup, you can still use this script, just change the lines 82, 93, 99 and 144, to whatever command line uploader you use.

Considerations

  1. The folders/files must have be modified at least 2 minutes ago (to avoid start uploading while the folder is still being updated)

  2. Every time you start the script, it will consider the files inside the folder as new and will upload them. The goal, is to start once and leave it running forever.

  3. Only the first level folders/files are considered. If you add a file inside <folder_that_you_want_to_monitor>/<already_uploaded_folder>/<new_file> it won't find the file and it won't upload the <alread_uploaded_folder> again.