UNIX / Linux: Kill All My Jobs Under Current Shell Session

How do I kill all the UNIX jobs I created under my current login shell such as Bash or KSH before logout?

All your jobs running in background or suspended mode can be listed with the job command. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following to examine the current jobs list:
$ jobs
Sample outputs:

[1]-  Running                 ping google.com > /dev/null &
[2]+  Stopped                 ftp ftp.freebsd.org
[3]-  Running                 rsync -ar vivek@r.lan.vip.nixcraft.net.in:/backup/tree/ ~/.tree/ >/dev/null &

To list its PIDs, enter:
$ jobs -p
Sample outputs:


To kill all the jobs running under the ksh or bash shell, enter:
$ kill `jobs -p`
$ kill $(jobs -p)
You can also kill single job using pid. For example, kill ftp ftp.freebsd.org job having PID # 6021 as follows:
$ kill -9 6021
Sample outputs (hit [Enter] key to processed):

[2]+  Killed                  ftp ftp.freebsd.org

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

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

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts