interrupt a background process

Asked by Julianloui on 2013-01-07

What instructions can I include in a script to cause it to pause and respond to a keyboard interrupt such as ^C while it is executing background processes?

Question information

English Edit question
Ubuntu bash Edit question
No assignee Edit question
Last query:
Last reply:

you can use:

echo "Press ENTER to continue"
read somevar

Then you will need to press ENTER for the script to continue. Is this what you mean?

You can also add:

echo "Waiting 1 minute"
sleep 60

To add a pause in a script

Midnight Matt (randygaffer) said : #3

If the script is running in the foreground, it doesn't need any other interrupting for it
 to respond to keyboard commands involving the control key, such as ^Z (suspend) or ^C (stop). If you want, however, your script can be put into a `while` loop that will cause it to execute only when you press the ENTER key.

while [[ -z $(read Varname) ]]; do

Can you help with this problem?

Provide an answer of your own, or ask Julianloui for more information if necessary.

To post a message you must log in.