Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Log what is being written to swap

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
serene
LXF regular


Joined: Sun Jun 19, 2005 1:43 pm
Posts: 111

PostPosted: Sun Apr 14, 2013 7:02 pm    Post subject: Log what is being written to swap Reply with quote

For a laptop with 16 G memory, that never suspends or hibernates... I'm considering disabling the swap partition.

Could someone please recommend a short bash script to log details for what exactly (if any) activity is being writen to the swap partition ?

Thank you
Serene
Back to top
View user's profile Send private message
purplepenguin
LXF regular


Joined: Wed Oct 05, 2011 3:19 pm
Posts: 110
Location: Blissfully at the Command Line

PostPosted: Mon Apr 15, 2013 5:32 pm    Post subject: Reply with quote

Code:
sudo top | grep Swap


Will output the swap usage to the terminal. It updates every few secs or so.

I just tried
Code:
sudo top | grep Swap >> swap.txt


The file swap.txt was created but nothing was written to it?

Hope this helps.

Edit**

I left the command running whilst I had my tea. When I came back there was data written to the file.

You could pop the command in a executable file and create a cron job to run it, or just start it when you want to monitor your swap usage.
_________________
I feel the need... The need for speed.
Crunchbang 64bit i5 CPU 8GB RAM
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8369
Location: Warrington, UK

PostPosted: Mon Apr 15, 2013 11:39 pm    Post subject: Reply with quote

You don't need to run it with cron, it keeps running the way you have run it and will keep filling the file. By default, it updates every three seconds, which will soon be a lot of data. You can change this with -d.

BTW, top runs as a user, you don't need to use sudo.

You may be better off using a combination of swapon and watch

Code:
watch /sbin/swapon -s

_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
serene
LXF regular


Joined: Sun Jun 19, 2005 1:43 pm
Posts: 111

PostPosted: Wed Apr 17, 2013 9:43 pm    Post subject: Reply with quote

Thank you both.

This is a little difficult to record due to the swap isn't being used for anything. Which stress test would you use to force the swap to be read and written to .


Thank you.
Serene
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8369
Location: Warrington, UK

PostPosted: Wed Apr 17, 2013 9:46 pm    Post subject: Reply with quote

Loading a shedload of large digital photos into GIMP always does it for me Smile
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
serene
LXF regular


Joined: Sun Jun 19, 2005 1:43 pm
Posts: 111

PostPosted: Fri Apr 19, 2013 3:01 pm    Post subject: Reply with quote

Will follow up, thanks.

Cheers

Serene



[SOLVED]
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast