Hi, my script is waiting for 3 files to come to a folder for 30 min but even when all the files arrive in the folder it's still waiting for these three files. Files can come with in 2 min and I want it to start processing them immediately after all the files arrive in the folder.
until [ `ls *.csv | wc -l` -eq 3 ]; do
sleep 1800
mailx -s "files are missing"
done
I have tried using until [[ `ls *.csv | wc -l` -eq "3" ]]; do
thanks in advance for your time.
You should use code tags and post the output that you're getting.
Aside from the fact using ls in loop or script is generally a bad idea, you don't have a space between ls and *.csv.
Hi, my script is waiting for 3 files to come to a folder for 30 min but even when all the files arrive in the folder it's still waiting for these three files. Files can come with in 2 min and I want it to start processing them immediately after all the files arrive in the folder.
until [ `ls *.csv | wc -l` -eq 3 ]; do
sleep 1800
mailx -s "files are missing"
done
I have tried using until [[ `ls *.csv | wc -l` -eq "3" ]]; do
thanks in advance for your time.
There is a space in ls and *.csv in the actual code. while posting here it was removed by mistake. Whenever it doesn't find all the 3 files it sent out the error email.
thanks
This will probably help
#!/bin/ksh
while [ "forever" ]
do
if [[ -s <filename> ]];
then
echo "file exists" >> /dev/null
break
else
sleep 1000
echo "Still file is not present" >> /dev/null
fi
done
echo "The script exits since file is present"
Here i am checking for size is > 0 .. You can also use -e to see if file exists.