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:
6020 6021 6023
To kill all the jobs running under the ksh or bash shell, enter:
$ kill `jobs -p`
OR
$ 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
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |