FreeBSD : Job management

Most of the new comers in UNIX world aware of ‘How to start a application, job, or even background process from command line’. However shell offers extensive job control like
putting a running job in the background, suspend a job, list it, restart it and so on!


A) To start a job in background use following syntax:
command-name &

You would like to start xmms to listen mp3s, you start it using following command:
xmms &

In reality many time you forget to append & at the end and your command; most of the us hit CTRL+C to cancel the xmms and restart it with appending & to it. However, you can take advantage of job management as follows:

i)Start command in background without appending &
$ xmms

ii)Press CTRL+Z to suspend it (you will get job number on screen)
[1]+ Stopped gpdf

iii) Type % &
job-number & (remember % refer to last suspended job so no need to type job number)

$ % &


$ 1% &
[1]+ gpdf &

This will save lot of time for example if you are running a job at shell prompt, and it is taking lots of time. Then use above trick. However, classic book on UNIX suggest following steps:

a) Start a job
$ xmms

b) Hit CTRL+Z to suspend it

c) Lists the active jobs with jobs command:
$ jobs
[1]- Running gpdf &
[2]+ Stopped vi

d) Place a job (with given number) in the background
$ bg %2

e) If you wish you can also put a job in foreground with command:
$ fg %2

f) You can list only job numbers with
$ jobs -p

g) Naturally kill all your jobs using kill command:
$ kill -9 $(jobs -p)
$ kill -9 `jobs -p`

Please note that job management is shell feature and almost available on all type of UNIX/BSD/Linux operating systems. Therefore, commands discussed here should work on Linux, Solaris, HP-UX et all.

1) Read man page of bash
2) Read help pages for bg, fg,and jobs commands, for example:
$ help jobs
3) See screen shot of above commands.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

4 comments… add one
  • Anonymous Jun 19, 2005 @ 21:45

    >$ 1% &
    >[1]+ gpdf &
    OR simply
    $ bg [ENTER]

  • 🐧 Vivek Gite Jun 20, 2005 @ 0:23

    > $ bg [ENTER]

    Yup, you can do that! Thanks for pointing out.

    Appreciate your post.

  • chuck Aug 9, 2012 @ 15:06

    “i)Start command in background without appending &
    $ xmms”

    dont’ you mean

    i)Start command in background without suspending
    $ xmms

  • gthf Oct 30, 2012 @ 1:38

    $ 1% &
    [1]+ gpdf &

    should be:

    $ %1 &
    [1]+ gpdf &

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.