.comment-link {margin-left:.6em;}

IntTech

Saturday, February 28, 2015

Linux Swap Files

This technique for adding swap space was used in the early days of linux on adhoc home systems.  It is not used much anymore, but maybe helpful with small cloud server systems.  Swap usage could be monitored as a way to detect low memory situations and buy the system a few seconds longer to alert or trigger a response before crashing from being out of memory.  

Pulled from this old RedHat documentation. Below is an example of creating a 512MB swap file. 

dd if=/dev/zero of=/var/swap bs=4096 count=131072
mkswap /var/swap

Then Add the following to /etc/fstab:
/var/swap     swap    swap   defaults  0 0 

On reboot the system will use the file as swap space.  To use it immediately issue the command: 
swapon /swapfile 

I know this works on Centos and Amazon linux, I expect it to work on all flavors of Linux. 


Bookmark and Share

Saturday, February 21, 2015

Ways to Connect AWS VPCs

Here is come useful reading on ways to connect AWS VPCs across regions. 

Bookmark and Share

Monday, February 10, 2014

Size of MySql Databases

This seems to work pretty well.
 SELECT table_schema "DB Name", 
   sum( data_length + index_length ) / 1024 / 1024 "DB Size in MB" 
   FROM information_schema.TABLES GROUP BY table_schema ; 

Bookmark and Share

Sunday, January 26, 2014

Fixing ^M in text using VIM

It is easiest to select your text block in visual mode, "v".  Then enter s/^M/\r/g. 
Keys for this is v for visual mode, then use cursor movement to select the text. 
Then : to give a prompt that looks like :'<,'>. 

Then s/ to give the s/^M, the rest should be self explanatory. 

Bookmark and Share

Wednesday, July 14, 2010

Chrome Feature

Just learned about the chrome://plugins/ feature for chrome browser. Works on Mac too!

Bookmark and Share

Saturday, June 26, 2010

Windows 7 Undock and Hibernate

New job has me using Windows 7 on a laptop. It seems less stable than Windows 2000. It has an undock feature on the "shutdown" menu. The problem is that 90% of the time I undock, I also want the laptop to hibernate. The other 10% of the time I want to undock to carry my laptop to a meeting. There is no "undock and hibernate" option separate from the plan undock on the menu. To do it properly you would have to undock, pop open the laptop and select hibernate. A real pain...

So thinking like a unix user, I figured there must be a way to do this on the command line. And here we go a short bat file to undock and hibernate. Copy the following lines and put them in a file. I called it gohome.bat.

: This Undocks
C:\Windows\System32\rundll32 cfgmgr32.dll,CM_Request_Eject_PC
:: Then we Hibernate
C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Hibernation has to be enabled for the last line to hibernate. Now I just double click the bat file on my desk top, and I'm off.

Bookmark and Share

Friday, March 26, 2010

Compressing or Removing Old Logs


The following is useful for compressing or removing files based on name.
 find $path -name "$LogFileRegEx" -exec $compress_rm {} \; & 

And this works for removing files based on age.
find $path -mtime $DaysToOld -exec rm {} \;

And they can be combined if needed.

Bookmark and Share

Google