

In addition to that, we used the grep command to filter the memory-related information. Here, we’ve used the same top command we tried before. Let’s see how that works: $ top -b -d1 -o +%MEM | grep -A1 'KiB Mem' On the other hand, if we just wanted to log the overall memory consumption, we can use the grep command to filter just that. With this, we can also see the process which uses more memory. This command will log details of all processes to the memory.log file. -o +%MEM: override the default sort option to use the %MEM column value the + sign is used to sort in descending order.-d1: set a delay of 1 second between each result.-b: enable batch mode and don’t accept input from the user.Let’s check the different options we’ve used here: And it’ll have the result of the top command every second. The above command redirects the result to the memory.log file.
