ps Display Width in OS X

In one of my OS X scripts, I used the following to check the running process.

If you’re thinking about purchasing a new GPU, we’d greatly appreciate it if you used our Amazon Associate links. The price you pay will be exactly the same, but Amazon provides us with a small commission for each purchase. It’s a simple way to support our site and helps us keep creating useful content for you. Recommended GPUs: RTX 5090, RTX 5080, and RTX 5070. #ad

ps -aux | grep '/etc/bkupexec/agent.be'

However, it doesn’t always work. I didn’t know exactly why. On one occasion, I found that if I run the script in a wide window and it works every time. I knew that it’s related to the window size then. How do I set it so that the script runs regardless the window size. The answer is right in the manual page.

-w      Use 132 columns to display information, instead of the default

        which is your window size.  If the -w option is specified more

        than once, ps will use as many columns as necessary without

        regard for your window size.

After I changed the script to

ps -auxww | grep '/etc/bkupexec/agent.be'

, it runs flawlessly every time.

3 Comments

  1. Unbelievable!

    I’ve had this exact same issue pop up, most recently this week, when I was out of town and remotely connected to my Mac to see if I left Mail running. According to the output of ps -aux, I wasn’t. When I got home, and widened the window, sure enough, it was running!

    Amazing timing of your note. Thanks!

    John

Leave a Reply