2

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?

3

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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