Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to write a simple Korn shell script to execute a loading process. The process occasionally runs into connectivity issues, so I need to kill it if it runs too long.

I have been trying the following code:

#!/usr/bin/ksh 
. /home/dw/script/load.ksh &
LOADPID=$!
sleep 100
kill $LOADPID

Unfortunately, the kill command does not kill the process - am I missing something?

share|improve this question

1 Answer 1

Try kill -s HUP "$LOADPID". And if it still doesn't work, you could try kill -s KILL "$LOADPID".

Also note that it doesn't make sense to run the . command in background (that is in another process) as the whole point of the . command is to interpret the code in the given file in the current shell process.

share|improve this answer
1  
Running . /some/script & does have a few uses: the script is executed by the same interpreter, and inherits shell parameters, functions, etc. However none of this is happening in this specific example. –  Gilles Nov 2 '12 at 22:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.