Why use tools when you can create your own.

When you run px aux we can see multiple status.


We will try to gather few data from here by reading the proc files in linux system:

  • In Linux, Each process is given a unique PID.
  • CPU% shows the cpu utilized by the given process.
  • The name of process are shown in COMMAND.
  • TIME is the time in seconds from when the system was running.

This articles is increment over  this article.

/proc/PID -> list of pid

Try the following command in terminal to filter the PID from ps aux

$ ps aux|awk ‘{print $2}’

Now, if you go to proc folders you can see multiple folders with integers name. Each folder represents the process running in the system and the status regarding it.

$ ls /proc/|grep -ioE “[0–9]”

Weirdly enough all the folders with numbers that you see in the proc folder are the same ones you see in the PID of ps aux command. Fun fact about the folders are that their size is 0. It contains multiple files inside it_._

#shell #go #linux #golang

Monitor Processes in Linux with Custom Script
1.10 GEEK