<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello everyone!<br>
<br>
How can I detect if a folder have changed (sync logic) than run a
script if it's true?<br>
I found this script over the net, but I think it's such complicated for
that simple thing...<br>
<br>
<blockquote>
  <p>#!/bin/bash</p>
  <p>############### detectdir.sh by Jagbir Singh #################<br>
#<br>
# script to detect changes in directory.<br>
#<br>
###############################################################</p>
  <p># directory to watch<br>
DIR=”/var/www/vhosts”</p>
  <p># store current statistics of dir<br>
OLD=`stat -t $DIR`</p>
  <p>while true<br>
do</p>
  <p> # take a new snapshot of stats<br>
NEW=`stat -t $DIR`</p>
  <p> # compare it with old<br>
if [ "$NEW" != "$OLD" ]; then</p>
  <p> echo “changed!” ## you may want to comment this</p>
  <p> # take current listing of dir in a file. domains may be added or
removed.<br>
ls $DIR –file-type | grep “\/” | sed ’s/\///’ > /tmp/dir.list</p>
  <p> # open file and you can now process entries in it<br>
exec 10<br>
let count=0</p>
  <p> while read LINE <&10; do</p>
  <p> # currently printed on screen, can supply this as arg to rSync,
discussed later<br>
echo $LINE/httpdocs/<br>
echo<br>
((count++))<br>
done</p>
  <p> # take snapshot again and store it in both old and new vars<br>
NEW=`stat -t $DIR`<br>
OLD=$NEW<br>
exec 10>&-<br>
fi</p>
  <p> # i’m using 3 secs calm time, you should update this as per your
environment<br>
sleep 3<br>
done
  </p>
</blockquote>
<br>
</body>
</html>