2

i have the following bash script:

#!/bin/sh
dir1=/source/dir/path/
while inotifywait -qqre modify "$dir1"; do
   rm -r /destination/dir/path
   find /source/dir/path/ -name .svn -exec rm -rf '{}' \;
   cp -ruv /source/dir/path/* /destination/dir/path/
done

the thing is that the first 2 commands are working well but the process is killed after executing (successfully) the "find -exec" command. Any thoughts?

BTW- if i remove the "find -exec" everything goes well.

  • I'm curious how this works at all. The inotifywait man page says it only exits with status 1, 2, or 3. No status 0. Thus the while inotifywait should never work as it doesn't exit with status 0. – Patrick May 10 '14 at 22:09
  • well it does work... i was following your link in my other question link – Ori Price May 10 '14 at 22:28
  • Am I understanding correctly… the »process is killed« means the script exits before executing the cp? Could you try adding set -e at the beginning of the script? If this does not give any clue, you could try doing strace find instead of the sole find (and eventually post the output somewhere and give us a link). – Andreas Wiese May 10 '14 at 22:37
  • @Patrick On Slackware there's the 0 exit status and perhaps on CentOS too. Also there's no 3 exit status. – slackmart May 10 '14 at 22:53
  • I am curious too, so @OriPrice I am guessing you are looking for svn files. Maybe using: find /source/dir/path/ -name '*.svn' -exec rm -rf '{}' \; works better. – slackmart May 10 '14 at 22:54
1

Try this (note the !)

dir1=/source/dir/path/
while ! inotifywait -qqre modify "$dir1"; do
   rm -r /destination/dir/path
   find /source/dir/path/ -name .svn -exec rm -rf '{}' \;
   cp -ruv /source/dir/path/* /destination/dir/path/
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.