Monitoring Processes on the Command Line

Updated 2012-11-06 with an alternative.

Sometimes you have a long running process that is firing off many commands in a row and you don’t get much output from the command. I like to have an idea of what’s happening, so I employ a simple Bash script that I’ve hand typed a million times. It keeps just the data I want on screen and auto-updates ever couple of seconds, so I can keep an eye on it while I’m working.

while true
    # Some command goes here
    sleep 2

If you have any modern shell, you can type this in with the line breaks. Now I have a clear console that is showing me just the data I want.

How do I use this? Right now, I have an apt-mirror post mirror script that rsyncs multiple directories. This is an automated process that runs quietly, so I can use ps -ef | grep rsync to monitor the process. I’ve also used this to monitor massive file creation / deletions, so the command could be ls -l | wc -l to count the files in the director. I use Hylafax, so I can monitor the modems with faxstat -a.

An Alternative

After posting this article, it was brought to my attention that I could just use the watch command. As with a lot of complex technologies, you tend to learn to do something one way and stay oblivious to other possible ways. watch is part of the procps project, so instead of the above loop, you could use:

watch "ps -ef | grep rsync"

This by default runs the given command every 2 seconds. Check out the man page for more options.

Unfortunately, watch is not part of the default UNIX stack on OS X. It seems to be available in Homebrew, but since it isn’t already on my system, I’ll probably stick with the bash script. Old habits die hard.

Monitoring Processes on the Command Line

My Experience Trying To Trade-In A Device

I normally sell or hand down my old tech to friends and family, but I decided to give one of these tech trade-in companies a whirl. When handing my things down, I ask for little to no money for the device, since I can’t justify high prices to my closest acquaintances. Of course, nothing goes easily, so here is my account of my experiences.

TL;DR Selling to Amazon and Gazelle can lead to a bumpy ride Trade-In Store

My first attempt was with Amazon. I’ve shopped there for years, I’m a Prime member and a good friend just sold the exact same device and got a pretty good deal.

Amazon’s process is as follows:

  1. Tell them what kind of item you have.
  2. Get an estimate of the value of your goods.
  3. Print out a free shipping label.
  4. Box up your items and ship them out.
  5. PROFIT!

I grabbed my original iPad, packed it my iPad 3 box, put that in another box with packing material and shipped it off. This is cheap shipping, so I waited about a week. Finally, an email showed up. How much money was I going to get? I was estimated ~$220.00. Amazon’s offer: $0.00.

What?! The Trade-In site claimed the device had minor cracks and dents. I fired off an email to Amazon to ask what happened. The device I sent was used, but it was in perfect working condition. Did UPS break it? Did Amazon break it?

The response I received can be summed up as:

  • Sorry for the problems…
  • Our system says the problem is Minor cracks or dents.
  • Here’s a $50 credit for your problems.
  • We’re sending your device back to you.

At this point, I was fuming. I went from a device I could have gotten $200+ dollars for, to a $50 Amazon credit and broken iPad. The device showed up a week later. I cautiously opened the box and to my surprise, the iPad was in the exact same condition I sent it in. I plugged it in, powered it up and had a fully working iPad. The only “problem” with it was a drained battery from being in the mail for 2 weeks. I tested it to make sure there wasn’t a faulty battery, but all of my tests came back that this device was fine.



Since I again had a fully working device, I decided I’d try Gazelle. I’ve seen the TV ads, I’ve heard the commercials on podcasts, so why not try it out. Couldn’t. Be. Simpler.

Gazelle’s process is as follows:

  1. Enter the devices you want to trade-in.
  2. Get an estimate of your trade-in value.
  3. Wait for a box to show up in the mail.
  4. Send off your device.
  5. PROFIT!

So, I went through the same steps. Pack it up, ship it off and wait. After about a week, I receive my first email, stating they received my package and that they will be checking it soon. The next day, I receive and email that they haven’t received my package yet.

Great! Another issue with this trade-in. An email conversation over the next couple of days assured me that they did have the device and the second email was just a glitch. They were currently overwhelmed, being the week before the iPhone 5 announcement, and that they will process the device soon.

A couple of days later, I get my offer email. Gazelle was originally going to offer me ~$180 for the device. The offer: $40.00. The device does not power on.

Again?! Trying to contain my rage, I email Gazelle and politely ask them to try again. The device has been in the mail and in warehouses for 2+ weeks, so the battery is probably drained. The support person said they would check it again.

Two days later, I get another email from Gazelle. The summary: “You’re right, we’ll send you $180.”


The Moral of the Story

I’ve had friends that have had no issues with these services. I’ve heard testimonials from trusted podcasters that this stuff is simple and quick. After over a month of stress, I went from ~$220 in store credit to $230 in cash and in store credit.

Unless the offer is amazing, I’m going back to hand-me-downs. I don’t have time to deal with managing this process.

My Experience Trying To Trade-In A Device