[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [riminilug-general] Programma per controllare le modifiche inuna directory



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 24 May 2004 16:50, Alessandro Carichini wrote:

dimenticavo:

zolfo:~# cat rsync_check_still_writing
#!/bin/bash
# this script gets executed by dnotify

# still receiving
touch /tmp/flag

# is rsync script started?
if [ ! -e /tmp/my_rsync ]; then
    (# if not, then execute in separate subshell
    while (touch /tmp/my_rsync); do
      # show that script is running and hasn't choked
      now=`date +%s`
      last=`date -r /tmp/flag +%s 2> /dev/null`
      count=$(($now - $last))
      timeout=2
      # check if still receiving
      if [ $((count)) -gt $((timeout)) ]; then
        # if not, then do rsync
        rsync
        # and remove flags
        rm -f /tmp/flag
        rm -f /tmp/my_rsync
        # and exit subprocess
        exit(0)
      fi
      # loop every 4 seconds
      sleep 4
    done)&
    # all the above gets executed in background in a sub-shell
fi # end of the main script
zolfo:~#

daniele
- -- 
PGP Key-ID: 0xF482D454
- --
To bodly go where no man has gone before.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAshBs8Tj5mfSC1FQRAgeNAKCD+juBy5eqon9p9FjUVVsSpvESDwCgiqiA
lMi2d1H3lhqqzK/5AeiPPV0=
=PGl9
-----END PGP SIGNATURE-----