I have written a bash script which detects if a
.ldif file has been written into a directory and if written, executes an
ldapadd command and then deletes that file. The scripts is as follows:
dir="/home/myuser/newldif/" while inotifywait -e create "$dir"; do ldapadd -w "ldappassword" -D "cn=Manager,dc=mydomain,dc=com" -f /home/myuser/newldif/user.ldif rm -rf /home/myuser/newldif/user.ldif done
The script is executed like so:
nohup ./testscript &
newldif is initially empty. When the file
user.ldif is copied to this location, the script executes but skips the
ldapadd command and executes the
On the other hand, when I execute the script without
inotify (i.e. I removed the
while loop completely), it adds the ldap entry and then deletes the file.
Is there anything wrong with the inotify syntax? The slapd logs don't show any errors. The
nohup.out file simply shows the following output:
Setting up watches. Watches established. Setting up watches. Watches established. Setting up watches. Watches established.
(each "Setting up watches." statement is for one deleted file)
The OS is CentOS 6.4 and OpenLDAP version is openldap-2.4.23.