dpmurphy Posted May 29, 2019 Report Share Posted May 29, 2019 I use ResilioSync to move files from one server to another across the country. I have a script that I wrote (that I trigger manually) that processes the file on the receiving end and moves it out of the "incoming" folder. This part is working flawlessly. I'm trying to figure out a way to automatically trigger my script when a new file has finished transferring via Resilio Sync. Any suggestions? Quote Link to comment Share on other sites More sharing options...
luckman212 Posted June 6, 2019 Report Share Posted June 6, 2019 What type of system(s) are these? Linux, macOS, Windows? Should be pretty easy to periodically run a script that compares the hash of a file to a previously known value and does something when it changes. If your system is Linux you can run the script every minute with cron etc. Here's a bash script I slapped together... you'll need the sha256sum binary, which you can get for just about any platform. See GNU coreutils or if you're on macOS and have Homebrew, `brew install coreutils`. This won't work for Windows but something similar can be done in PowerShell if needed. #!/usr/bin/env bash function calculateHash() { sha256sum "$srcfile" >"$oldhash" return } [ $# == 0 ] && { echo "usage: $0 <filename>"; exit; } srcfile="$1" fName="${srcfile##*/}" oldhash="/tmp/$fName.sha256sum" if [ ! -e "$oldhash" ]; then echo "creating hashfile for $fName" calculateHash exit fi if sha256sum -c --quiet "$oldhash"; then echo "hashes match, taking no action" else echo "file change detected! doing stuff..." # do stuff here # calculateHash fi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.