How to check how much RAM your web-app is consuming? And which process is consuming more RAM? Read below to know about how to check RAM usage on a Linux server.
Check RAM Usage
To check how much ram is being used by your server run below command.
free -m
This will show a status of RAM being used. Parameter -m used will convert KBs to MBs.
The above command will only show you a snapshot of Memory usage at that instant. What if you want to monitor the RAM usage? Add “-s 1” to refresh the status after every 1 second.
free -m -s 1
Command to list Running Processes on Server
To check all the processes running on server run below command.
ps aux | awk ‘{print $6/1024 ” MB\t\t” $11}’ | sort -n
The above command will show all the processes along with their RAM usage in MBs. It will also sort the results to show high RAM usage at bottom.
What if you want to filter your processes. Like if you want to see only apache instances. Run below command.
ps aux | grep apache | awk ‘{print $6/1024 ” MB\t\t” $11}’ | sort -n
You can change apache to any other keyword to search in process names.