What does the command pkill -USR1 -n -x dd mean exactly

ddkillsignals

I am using dd to do a network transfer of a disk image to an sd card on my BeagleBone.

Using pkill -USR1 -n -x dd in an ssh connection to this BeagleBone gives me a status update of the transfer process, which is great. I am just curious how it is actually working so I can use it effectively in the future.

After reading man pkill it still didn't totally explain how pkill -USR1 -n -x dd is working to give me this very useful status update.

Best Answer

This is behavior specific to dd. From the dd man page:

Sending a USR1 signal to a running 'dd' process makes it print I/O statistics to standard error and then resume copying.

$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid

18335302+0 records in 18335302+0 records out 9387674624 bytes (9.4 GB) copied,  34.6279  seconds, 271 MB/s

-USR1 tells pkill to send the USR1 signal. -n and -x are just filters to make sure you send to the right process (-n sends to the newest process and -x means the process must be named exactly dd)

Related Question