Monday, May 25, 2015

Logrotate uses 100% CPU issue on CentOS

A typical /var/lib/logrotate.status looks like:

logrotate state -- version 2
"/var/log/daemon.log" 2015-5-9
"/var/log/portage/elog/summary.log" 2015-5-9
"/var/log/mysql/mysql.err" 2015-5-9
"/var/log/mysql/mysql.log" 2015-5-9
"/var/log/mysql/mysqld.err" 2015-5-9
"/var/log/atop/dummy_before" 2015-5-25
"/var/log/atop/dummy_after" 2015-5-25
"/var/log/net-snmpd.log" 2015-5-9
"/var/log/xinetd.log" 2015-5-23
"/var/log/wtmp" 2015-5-9

It is a small file say hundred bytes, but the size may reaches megabytes if there are some config errors.

Following command can be used to check the configuration of logrotate without change anything:

sudo /usr/sbin/logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file daemon
reading config info for /var/log/daemon.log
reading config file elog-save-summary
reading config info for /var/log/portage/elog/summary.log
reading config file mysql
...

It may indicate a bad logrotate.status file if the command hangs with a huge logrotate status file,  

To fix the problem, simply delete the logrotate.status. The logrotate will re-create a new one for you.


Sunday, April 26, 2015

SVN client side problems

If there is a performance or strange issue on a specific tree try the following:


  1. In Windows, delete the roaming profile folder %AppData%\Subversion. 
  2. Rename your current tree then chekout a fresh copy to work with. Then copy any uncommitted files from the old (renamed) tree to the new tree.  

Monday, January 12, 2015

Setup Color Scheme Distinguished For Vim

Run mkdir -p ~/.vim/colors

Download distinguished.vim and move to the directory.

Add following to ~/.vimrc
syntax on
colorscheme distinguished

Append following to ~/.bashrc
        export TERM=xterm-256color

Run . ~/.bashrc to bring up the term setting.

For more schemes examples see http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own

Monday, December 22, 2014

Excel VBA - Misc File Handling Subroutines



Sub CopyFile()
    FileCopy "fullPATH\filename1", "fullPATH\filename2"
End Sub

Sub renameFile()
    Name "fullPATH\oldFileName" As "fullPATH\newFileName"
End Sub

Copy With Destination Defined Makes Cleaner VBA Code

Following example code simplify the copy process by eliminating 4 line codes such as Range.copy, Sheet.Activate, Range.Select, and Activesheet.Paste.

    Range("B12:C17").Copy Destination:=Range("B30")

Even shorter:

    Range("B12:C17").Copy Range("B30")

Similarly, following code can be used for moving:

    Range("B12:C17").Cut Range("B30")

Excel VBA - Delete All Blank Lines in Work Sheet

Following subroutine deletes all blank lines from current work sheet from the bottom with the range defined A1:Z50.

Sub DeleteRowsFromBottom()
Dim range As range, rows As Integer, i As Integer
  
Set range = ActiveSheet.range("A1:Z50")
rows = range.rows.Count
For i = rows To 1 Step (-1)
    If WorksheetFunction.CountA(range.rows(i)) = 0 Then range.rows(i).Delete
Next

End Sub

Save Current Excel Workbook To A CSV Format File

Following code can be used to save the current work book into CSV format to the folder fullPATH and ignore the backup.

ActiveWorkbook.SaveAs Filename:= _
        "fullPATH\fileName.csv", FileFormat:= _
        xlCSV, CreateBackup:=False