"jobs" - Manage Background Jobs

This section provides a tutorial example on how to use 'jobs' command to display background jobs, which are processes with input detached the keyboard. You can start a background job by adding the 'ampersand' sign to the end of the commmad.

What Is Background Job? - A background job is a process with its input being detached from the keyboard device. Its output may still be attached to the screen.

A foreground job is a process with its input being attached to the keyboard device. When you enter a command at the shell prompt to start a process, it will be started as a foreground job by default. The keyboard will be occupied by this foreground job until it is terminated. So you can only executed 1 process job at any time.

If you want start a process as a background job to keep the keyboard free for the next process, you use the following 2 options:

1. Adding "&" at the end of the command line. This will start the process as a background job immediately. For example, the following command starts a process (ID=40120) as a background job (#=1).

herong$ sleep 100000 &
[1] 40120

2. Press "ctrl-z" during the execution of a foreground job. This will stop the foreground job and make it as a background job and keep it as stopped.

herong$ sleep 50000
ctrl-z
[2]+  Stopped                 sleep 50000

If you want to see a list of your own background jobs, you can use the "jobs" command:

herong$ jobs
[1]-  Running                 sleep 100000 &
[2]+  Stopped                 sleep 50000

If you want to resume a stopped job in the background, you can use the "bg #" command:

herong$ bg 2
[2]+ sleep 50000 &

herong$ jobs
[1]-  Running                 sleep 100000 &
[2]+  Running                 sleep 50000 &

If you want to bring a background job to the foreground, you can use the "fg" command:

herong$ fg 2
sleep 100000

One nice about running a command in the background is that it will to run, even if your shell session gets disconnected/closed.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

Process Management

 "ps" - Display Current Processes

"jobs" - Manage Background Jobs

 Cron Daemon, Table and Jobs

 "tmux" - Terminal Multiplexer

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB