I want to execute a shell script abc.ksh.
But I only want it to execute if file XYZ is not present.
If file XYZ is present than I want to unix to sleep for 5 Sec and than agaian check for XYX existence.
if it sleeps for more than 30 seconds ( 6 time )I want it to fail.
I am not good at UNIX.
I work in different technology
help will be appreciated.
I guess You mean that You want to run it, but only perform a specific operation if the file exists?
You can try this, modify it to Your needs,
retries=0
while true ; do
if [ -f XYZ ]; then
echo found file, performing operation and exiting
#more operations here
break
fi
retries=$((retries+1))
[ $retries -eq 7 ] && break
echo waiting for file...
sleep 5
echo retries=$retries
done