Shell script loop runs out of memory
Buchbinder, Barry (NIH/NIAID) [E]
BBuchbinder@niaid.nih.gov
Sun Jun 10 17:41:00 GMT 2012
Just to complete this topic ...
This gets rid of all the fork-execs in the inner loop except
for sleep. Instead of comparing file contents, it uses
the test builtin to compare time stamps.
------------------------
#!/bin/dash
FILE_TO_CHECK=/mypath/style.less
COMPARE_FILE=/mypath/compare_file.tmp
echo -n > $COMPARE_FILE
while [ 1 = 1 ]
do
echo "Waiting for file to change..."
while [ 1 = 1 ]
do
if [ $FILE_TO_CHECK -nt $COMPARE_FILE ]
then
break
fi
sleep 1
done
echo -n > ${COMPARE_FILE}
echo "File was modified ... Running compiler..."
/mypath/lessc $FILE_TO_CHECK /mypath/style.css -x
done
------------------------
A question I have is whether using a DOS version of sleep would
avoid the consumption of resources. In other words, is the
problem caused by the fork-exec or launching a new cygwin
process. If the latter, might that be avoid by use of a DOS
version of sleep? (I have one if the OP wants to try it.)
I apologize for taking so long to post this.
- Barry
Disclaimer: Statements made herein are not made on behalf of NIAID.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list