Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

There are many other parameters for ps, including a large number of options
for compatibility with other UNIXes, all of which can be found in the man
page.


Listing Jobs with jobs


A job is any program you interactively start that doesn’t then detach from the
user and run on its own (like a daemon does). If you’re running an interactive
program, you can press Ctrl+Z to suspend it. Then you can start it back in the
foreground (using fg, covered next) or in the background (using bg, covered
with fg).


While the program is suspended or running in the background, you can start
another program. Then you have two jobs running. You can also start a
program running in the background by appending an & like this:


Click here to view code image
matthew@seymour:~$ programname &


When started this way, a program runs as a background job. To list all the jobs
you are running, you can use jobs:


Click here to view code image
matthew@seymour:~$ jobs


There are several useful parameters you can use with jobs, including the
following:


-l—Lists    the process IDs along   with    the normal  output
-n—Displays information only about jobs that have changed status since
the user was last notified of their status
-r—Restricts output to running jobs
-s—Restricts output to stopped jobs

Running One or More Tasks in the Background


Put the & (ampersand) symbol at the end of any command to make it run in
the background:


Click here to view code image
matthew@seymour:~$ command &
[1] 11423

Free download pdf