The Power Of CTRL+T

Did you know that you can check what a process is doing by pressing CTRL+T?
Has it happened to you before that you were waiting for something to be finished that can take a lot of time, but there is no easy way to check the status. Like a dd, cp, mv and many others. All you have to do is press CTRL+T where the process is running.  This will output what’s happening and will not interrupt or mess with it in any way. This causes the operating system to output the SIGINFO signal.
On FreeBSD it looks like this:

ping pingtest.com
PING pingtest.com (5.22.149.135): 56 data bytes
64 bytes from 5.22.149.135: icmp_seq=0 ttl=51 time=86.232 ms
64 bytes from 5.22.149.135: icmp_seq=1 ttl=51 time=85.477 ms
64 bytes from 5.22.149.135: icmp_seq=2 ttl=51 time=85.493 ms
64 bytes from 5.22.149.135: icmp_seq=3 ttl=51 time=85.211 ms
64 bytes from 5.22.149.135: icmp_seq=4 ttl=51 time=86.002 ms
load: 1.12 cmd: ping 94371 [select] 4.70r 0.00u 0.00s 0% 2500k
5/5 packets received (100.0%) 85.211 min / 85.683 avg / 86.232 max

64 bytes from 5.22.149.135: icmp_seq=5 ttl=51 time=85.725 ms
64 bytes from 5.22.149.135: icmp_seq=6 ttl=51 time=85.510 ms

As you can see it not only outputs the name of the running command but the following parameters as well:
94371 – PID
4.70r – since when is the process running
0.00u – user time
0.00s – system time
0% – CPU usage
2500k – resident set size of the process or RSS

An even better example is with the following cp command:

cp FreeBSD-11.1-RELEASE-amd64-dvd1.iso /dev/null
load: 0.99 cmd: cp 94412 [runnable] 1.61r 0.00u 0.39s 3% 3100k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 15%
load: 0.91 cmd: cp 94412 [runnable] 2.91r 0.00u 0.80s 6% 3104k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 32%
load: 0.91 cmd: cp 94412 [runnable] 4.20r 0.00u 1.23s 9% 3104k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 49%
load: 0.91 cmd: cp 94412 [runnable] 5.43r 0.00u 1.64s 11% 3104k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 64%
load: 1.07 cmd: cp 94412 [runnable] 6.65r 0.00u 2.05s 13% 3104k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 79%
load: 1.07 cmd: cp 94412 [runnable] 7.87r 0.00u 2.43s 15% 3104k
FreeBSD-11.1-RELEASE-amd64-dvd1.iso -> /dev/null 95%

I prcessed CTRL+T six times.  Without that, all the output would have been is the first line.

Another example how the process is changing states:

wget https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-amd64-dvd1.iso
–2018-06-17 18:47:48– https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-amd64-dvd1.iso
Resolving download.freebsd.org (download.freebsd.org)… 96.47.72.72, 2610:1c1:1:606c::15:0
Connecting to download.freebsd.org (download.freebsd.org)|96.47.72.72|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3348465664 (3.1G) [application/octet-stream]
Saving to: ‘FreeBSD-11.1-RELEASE-amd64-dvd1.iso’

FreeBSD-11.1-RELEASE-amd64-dvd1.iso 1%[> ] 41.04M 527KB/s eta 26m 49sload: 4.95 cmd: wget 10152 waiting 0.48u 0.72s
FreeBSD-11.1-RELEASE-amd64-dvd1.iso 1%[> ] 49.41M 659KB/s eta 25m 29sload: 12.64 cmd: wget 10152 waiting 0.55u 0.85s
FreeBSD-11.1-RELEASE-amd64-dvd1.iso 2%[=> ] 75.58M 6.31MB/s eta 20m 6s load: 11.71 cmd: wget 10152 running 0.73u 1.19s
FreeBSD-11.1-RELEASE-amd64-dvd1.iso 2%[=> ] 85.63M 6.83MB/s eta 18m 58sload: 11.71 cmd: wget 10152 waiting 0.80u 1.32s
FreeBSD-11.1-RELEASE-amd64-dvd1.iso 14%[==============> ] 460.23M 7.01MB/s eta 9m 0s 1

The bad news is that CTRl+T doesn’t work with Linux kernel, but you can use it on MacOS/OS-X:

—> Fetching distfiles for gmp
—> Attempting to fetch gmp-6.1.2.tar.bz2 from https://distfiles.macports.org/gmp
—> Verifying checksums for gmp
—> Extracting gmp
—> Applying patches to gmp
—> Configuring gmp
load: 2.81 cmd: clang 74287 running 0.31u 0.28s

PS: If I recall correctly Feld showed me CTRL+T, thank you!

3 thoughts on “The Power Of CTRL+T”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.