Changing an already running job to execute in the background
For any *nix system, including the Mac, if you are running a job and it is taking longer than you expected, you can give up and sit there, or you can get fancy and have the already running job convert to running in the background. Here's the trick on how to do this.
First, we start a long running job like so:
Once this is running type Ctrl + Z. This will stop your job, but it will not kill it. You can then type jobs on the command line. This will show all jobs on the system. Here's the sample put you would see:
Now, to convert the job to running in the background, select the job number (there is only one in this case, and the job number is 1) and type the following on the command line:
where in this case, 1 is the job number to be run in the background. If you have multiple jobs running, you will need to enter the number that corresponds to the job you want to run in the background. If you then type the jobs command you'll see this output:
which indicates that the job is now running in the background. If you want to bring the job back to the foreground, you can use the fg comand like so:
where again the number 1 indicates the job to run in the foreground.
Using this command, you can save yourself from a long unexpected wait.
First, we start a long running job like so:
find / -name test -print
Once this is running type Ctrl + Z. This will stop your job, but it will not kill it. You can then type jobs on the command line. This will show all jobs on the system. Here's the sample put you would see:
[1]+ Stopped find / -name test -print
Now, to convert the job to running in the background, select the job number (there is only one in this case, and the job number is 1) and type the following on the command line:
bg %1
where in this case, 1 is the job number to be run in the background. If you have multiple jobs running, you will need to enter the number that corresponds to the job you want to run in the background. If you then type the jobs command you'll see this output:
[1]+ Running find / -name test -print &
which indicates that the job is now running in the background. If you want to bring the job back to the foreground, you can use the fg comand like so:
fg %1
where again the number 1 indicates the job to run in the foreground.
Using this command, you can save yourself from a long unexpected wait.
| Rating: | no ratings, 0 total Votes |
| Categories: | linux UNIX Mac |
| Added: | on Aug 06, 2007 at 11:57 am |
| Added By: | an anonymous user |

