On Wed, Oct 05, 2016 at 01:31:30PM -0700, Rich Shepard wrote:
> Starting a script to run in the background is simple: append '&' to the
> command line. When the script runs for a few hours and I forget to start it
> in the background (as I did today) I'd like to pause it (using ctrl-z) and
> continue running it in the background.
>
> My web searches show how to start scripts running in the background and
> how to pause them prior to bring them back to the foreground, but I missed
> seeing a solution to pausing then continuing processing in the background.
>
> Seems to me that I should be able to pause the running script (PID: 10952
> pts/0 S+ 0:00 sleep 15) or whatever the PID is when I pause the script, then
> run bg 10952 to re-start it in background mode. Is this correct?
Hmmm, how can we test this?
michael@bivy ~/testme % vi script.sh
michael@bivy ~/testme % cat script.sh
#!/bin/bash
for R in `seq 1 10000`
do
echo `date` >> output
sleep 2
done
michael@bivy ~/testme % ./script.sh
^Z
[1] + 28285 suspended ./script.sh
148 michael@bivy ~/testme % bg
[1] + 28285 continued ./script.sh
michael@bivy ~/testme % ls -l
total 8
-rw-r--r-- 1 michael michael 140 Oct 5 13:44 output
-rwxr-xr-x 1 michael michael 82 Oct 5 13:43 script.sh
michael@bivy ~/testme % ls -l
total 8
-rw-r--r-- 1 michael michael 196 Oct 5 13:44 output
-rwxr-xr-x 1 michael michael 82 Oct 5 13:43 script.sh
OH, output is getting larger. Script must be running.
Yes, that's how it works.
--
Michael Rasmussen, Portland Oregon
Be Appropriate && Follow Your Curiosity
Each day is a gift and not a given right.
~ http://someoneoncetoldme.com/gallery/05072010
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug