I don't know about you, but I'm not a fan of typing a command into the terminal and then nothing happening. Generally, any command that I know might take a while I'll run in verbose mode. That's great, I know that the process really is running. But what I don't know how far along it is...and how much more there is to go.
Today I found out about the
pv command. Boy, is that a game changer...
I stumbled upon
pv (short for Pipe Viewer) as I was wondering if there was anyway to know the status of MySQL import. Basically, you start out by running your input file through
pv and then piping that out to whatever command you were originally intending to run.
pv then keeps track of and reports on the status of wherever it's output is going.
pv shows the the amount of data transfered, the amount of time running, the transfer rate, a progress bar, the percentage complete, and an eta. I find the defaults to work perfectly, but if you'd like to tinker with things details on all the switches can be found here.
Head to the projects home page here for installation instructions. I was running
pv on a CentOS system and used the
yum package manager for installation.
While we're on the subject, it should be said that tmux is also a great tool for these types of long running jobs. If you don't know about it there's a great primer here.
While a MySQL import seems like one of the most common use cases for
pv, I anticipate I'll get additional mileage out of
pv down the road. For example, I can see myself using it one day when running a long
uniq command on a massive Apache log file.
How are you using
pv? I'd love to hear some more use cases in the comments.
Hi, I'm Max!
I'm a software developer who mainly works in PHP, but also dabbles in Ruby and Go. Technical topics that interest me are monitoring, security and performance.
During the day I solve challenging technical problems at Something Digital where I mainly work with the Magento platform. I also blog about tech, work on open source and hunt for bugs.
I built a tool called Domain Clamp which monitors and alerts about expiring domains and SSL certificates.
If you'd like to get in touch with me the best way is on Twitter.