0

This question is an exact duplicate of:

I just installed inotify-tools.

I would like to continuously detect change of chksum of files under folder /path

Once a change was detect ( under /path ) then it will print

echo “chksum of files under folder /path was change"

example how to check the chksum until now

find /path -type f -name "*.jar"  | xargs cksum | awk '{ sum += $1 } END { print sum }'

Little similar case is on:

https://superuser.com/questions/956311/continuously-detect-new-files-with-inotify-tools-within-multiple-directories-r

#!/bin/sh
MONITORDIR="/path/to/the/dir/to/monitor/"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
        echo "This is the body of your mail" | mailx -s "File ${NEWFILE} has been created" "yourmail@addresshere.tld"
done

marked as duplicate by Jeff Schaller May 23 at 1:34

This question was marked as an exact duplicate of an existing question.

  • I can see, you're using checksum only for alerting if any changes happen, using git for this purpose would be better, as this would allow you see the diff when any changes have been made and also allow you to keep or revert it to the previous commit if you need to. You'd just need to check git status --porcelain to detect any changes. Also, you'd be able to ignore some files with .gitignore. – GypsyCosmonaut May 22 at 18:25
  • Is this separate from unix.stackexchange.com/q/520433/117549?? – Jeff Schaller May 22 at 18:45