วันพุธที่ 27 ตุลาคม พ.ศ. 2553

split /var/log/message log

I'm using gentoo and vixie-cron as a system cron. After using it for a while, I found that gentoo store cron log in to /var/log/message. And, I just kind of like to split this for monitoring easily. Here is what I have done.

edit this :
/etc/syslog-ng/syslog-ng.conf

add the following lines :
filter f_cron { facility (cron); };
destination cron { file("/var/log/cron.log"); };
log { source(src); filter(f_cron); destination(cron); };

reload syslog-ng :
/etc/init.d/syslog-ng reload

you may need to setting the logrotate. Please see the example in /etc/logrotate.d/ for example

วันอังคารที่ 19 ตุลาคม พ.ศ. 2553

terminal key map

Some ssh client need config for special button.
You can use this value to map the keyboard button to this value perform function properly.

Home \033[1~
Delete \033[3~
End \033[4~
Page Up \033[5~
Page Down \033[6~

วันพุธที่ 6 ตุลาคม พ.ศ. 2553

find command with -exec options

find command is quite a handy tool for file searching. It can also include an command to execute for matched file with

1) -exec command ;
2) -exec command {} +

Both are different.
Let say you have 3 files, a b c in the directory.

#find . -exec echo '{}' >> tmp1 \;
output in tmp1 will be :
.
./b
./a
./c
./tmp1

#find . -exec echo '{}' >> tmp2 \+;
output in tmp2 will be :
a b c

with + all matched file will be append and execute once.
with ; all matched file will be execute for each matching.