Situatie
How to clear memory and swap in Linux environment using scripts and simple commands
Solutie
If the server is alerting that the RAM memory is full or the swap is full you can use these simple commands to clear them most of the time:
Log into the Linux server that has the problem
Check using top or htop
Use f10 to exit and f9 and then 9 to kill the processes that have a lot of load:
Afterwards using the command “service NameOfService restart” you will clear the memory. In this case “service mysqld restart”
To force the swap use the command “swapoff -a && swapon -a” and if the memory has enough space to get the swap amount it will do just so
Now the memory and the swap are clean.