Below is the script named bck_grd.sh
#!/bin/bash
i=2
while [ $i -gt 0 ]
do
echo HURRAY
done
When this infinite while loop is executed in foreground, it keeps on echoing message HURRAY and this script can be suspended by ^Z (ctrl+z)
Now if the same script is ran in background (i.e. bash bck_grd.sh &)then also it keeps on echoing message HURRAY and here if i try to suspend this script using ^Z, it doesn't work. and the terminal gets tied up in displaying HURRAY message.
My question here is how can i suspend the above script while running it in background
I am using Ubuntu-11.04
You can bring it to the foreground and then press
^Z:(note that you would type the
fgcommand while the script is echoing the output - it's okay, as long as you remember to press enter ;))