On Linux, the top command has a "batch mode": top -b -n 1 to print the output a set number of times. On Mac, it seems that the top command does not have batch mode (certainly the -b option does not exist).

How can I emulate top -b -n 1 on a Mac?

2 Answers 2


There's logging mode, with an argument specifying how often output will be repeated, 0 being until aborted. To print once and exit:

$ top -l 1
top -l3 -n30 > test ; tail -n42 ./test > ./test2 ; open ./test2

You need to repeat at least three times to have the correct CPU statistics, which is done by the option -l3.

I keep the 30 most important jobs, which I extract from the log file with tail.

top -l alone does not do the job for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .