hi,
my aim is to run a script in the background, and in the event that i need to cancel its execution, i'll just put a file name cancel to the execution directory of the script. if the cancel file exists, the whole script is expected to end and seize execution.
the problem is i cannot achieve that kind of effect...
#!/bin/sh
check_cancel() {
# this routine will check whether the file cancel exists
# if it exists, "this script" is expected to end execution
if [ -f `dirname ${0}`"/cancel" ]
then
rm `dirname ${0}`"/cancel"
exit
fi
}
while true
do
# check if a cancel file exists in the
# directory where the script is executed
check_cancel
while read LINE
do
check_cancel
sleep 1
echo ${LINE} > /dev/null
done < /var/adm/messages
done
i just used /var/adm/messages and echo to /dev/null to simulate some kind of processing.
thanks,
my aim is to run a script in the background, and in the event that i need to cancel its execution, i'll just put a file name cancel to the execution directory of the script. if the cancel file exists, the whole script is expected to end and seize execution.
the problem is i cannot achieve that kind of effect...
#!/bin/sh
check_cancel() {
# this routine will check whether the file cancel exists
# if it exists, "this script" is expected to end execution
if [ -f `dirname ${0}`"/cancel" ]
then
rm `dirname ${0}`"/cancel"
exit
fi
}
while true
do
# check if a cancel file exists in the
# directory where the script is executed
check_cancel
while read LINE
do
check_cancel
sleep 1
echo ${LINE} > /dev/null
done < /var/adm/messages
done
i just used /var/adm/messages and echo to /dev/null to simulate some kind of processing.
thanks,