How to monitor a unix directory and if any new file in directory it will be copied to another directory

cpinotifysolaris

I want to monitor a unix(Solaris 10) directory and if there is any new file I want to copy it immediately.

Tried:
I have shown inotifywait and incron package in Linux for it but I don't know whether it is compatible for unix or not. How I can perform this task in Solaris 10.

Be noted that I have root privilege.

Best Answer

You may use while loop...

for (( ; ; ))
do
cp -f /source/*.txt /destination >> /dev/null
sleep 2
done    

Used /dev/null to avoid displaying errors.

Related Question