I usually do this in a few steps. You do need to be root to do this. First I want to see what is currently being used.
free
Then I run the actual commands that empty the swap:
swapoff -a && swapon -a
Then I check what is being used after doing this.
free
I have these three steps in a script and then I just run the script, but, the commands could easily be run from the command line.

2 comments:
Thanx it help for me
Thanks. I had puzzling situation with 4G RAM mostly free but a whole G of swap in use.
Your command line cleared swap although I'm still a bit puzzled.
top shows Swap: 2031608k total, 0k used, 2031608k free, 2031472k cached
What is that cached swap?
colymoore@gmail.com
Post a Comment