What does “batch mode” mean for the top command?

Batch mode refers to batch processing, which means automated processing, without human intervention. Batch is the opposite of interactive.

In batch mode, top produces output that's more sensible for collecting to a log file or for parsing (though top isn't really good at producing parseable output even in batch mode). There is no limit on the number of output lines and the output doesn't contain any escape sequences for formatting.

In interactive mode, top produces output intended for human viewing. In particular, it only displays one screenful of data. The output contains some escape sequences for formatting. Top operates in interactive mode even when its output is redirected to a file; only the presence of the -b option matters.


1. Batch mode is useful if you want to save monitored data for later review or to analyze it with another program. You can use the collected data to generate custom log files (an example usage is described here), databases or even graphs that can be uploaded to a web server for remote monitoring. You can find batch output in many popular programs like the snort intrusion detection system.

2. The -b option tells top to use batch mode, which is machine readable. This means you don't get the fancy formatting (which you see while running top in interactive mode), but all data will be included. If you redirect top -n 5 to a file, you will only see those lines that fit on your screen. This is because top assumes that it is being run interactively and expects the user to scroll down if he wants to see all the lines. Try it yourself.