Basic Job Management

From LinuxReviews
Jump to navigationJump to search

If you are in a terminal console you can run commands and wait for them to finish. But you don't have to. If you want to launch a browser and keep on using the terminal you can start it as a "background" job by adding & to the command. Exapmle:

konqueror &

will start konqueror in the background. What if you forget & and want to put it in the background later? You can press ctrl-z to "stop" the "job" (in this case Konqueror). You will now get message saying [2]+ Stopped konqueror. That means Konqeruror is job #2 and it's stopped.

You can make that job a background job by typing bg 2 and put it back in the foreground with fg 2. You can just use bg or fg if there's just one job.

Now, if you run a program and press ctrl-Z - stopping that job - and you keep on using the terminal and forget about it and try to close the terminal with exit or ctrl-d you will get a message saying There are stopped jobs.. If that's the case you can just type fg and bring the job to the foreground. You can then terminate it by pressing ctrl-c.

The command jobs will list all the jobs you have running. Adding -l will list the PID (Process ID) of the various jobs. Thus, you can run jobs -l and then use kill PID to eradicate one of the jobs you have running. Adding -r will list only running jobs, -s will only list stopped jobs.


Questions?


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.