Friday, February 12, 2016

interrupt sleep in a bash script


For testing you have added sleep command in a script.

Now, you want to interrupt the sleep and continue to next statement.

How do you do it?

 Method 1:
If sleep is only done in your script alone, you can do this:
pkill sleep
 
Method 2: (need changes in script) 

--------------------- // this is your script
# write the current session's PID to file
echo $$ >> myscript.pid

# go to sleep for a long time
sleep 1000

---------------------
# pkill -P $(<myscript.pid) sleep 


Ref:
http://askubuntu.com/questions/575704/how-can-i-wake-a-sleeping-bash-script

No comments:

Post a Comment