i created one bash script named "quicktest.sh". the task of this script is to set inotifywait on Data folder from all users home directory.
the code of quicktest.sh is down below:
function inotify_data()
{
user="$1"
if [ -d /home/$user/Data ];
then
while read -r path action file; do
echo "The file '$file' created"
chmod 0777 -R /home/$user/Data
done < <(exec inotifywait -m -r /home/$user/Data -e moved_to -e create -e modify)
fi
}
cd /home/
ls >/tmp/.grp
i=1
n=`wc -l </tmp/.grp`
while [ "$i" -le "$n" ]
do
user=`awk "NR==$i" /tmp/.grp`
echo "setting watch on $user Data Folder."
inotify_data "$user" &
i=$((i+1))
done
i have 2 users in my machine, after running this script, i run "ps -ef | grep -i quicktest.sh" , then it will shows two process of this file.