個人常常使用time來看program跑多久,man time的說明中,有--verbose,還有format,但
# time -v ps aux
這樣都會有顯示
-bash: -v: command not found
real 0m0.001s
user 0m0.000s
sys 0m0.001s
後來才知道原來是bash這個shell中,time的指令沒有GNU版本的功能
所以怎麼跑GNU版本的time呢?
就是..
# /usr/bin/time -v ps aux
水啦~~~~^^
星期三, 3月 17, 2010
星期五, 1月 15, 2010
[Linux] vim 怎麼用?!
http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/
這位部落客,把Vim常用的部份給圖形化了,這真是太屌了~~~^^
vim的指令(command)不會,上鳥哥太慢~~~^^
有PDF可以下載嚕~~~^^
這位部落客,把Vim常用的部份給圖形化了,這真是太屌了~~~^^
vim的指令(command)不會,上鳥哥太慢~~~^^
有PDF可以下載嚕~~~^^
星期三, 1月 13, 2010
[Linux] About "kernel: TCP: time wait bucket table overflow"
tcp_max_tw_buckets
Maximal number of timewait sockets held by system simultaneously. If this number is exceeded TIME_WAIT socket is immediately destroyed and warning is printed. This limit exists only to prevent simple DoS attacks, you must not lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value (180000).
所以當你設小的時候呢,/var/log/messages就會出現一堆"kernel: TCP: time wait bucket table overflow",所以default值千萬別亂改,如果你的程式會有狠大的traffic
怎麼改回來呢?
在/etc/sysctl.conf加這行
net.ipv4.tcp_max_tw_buckets = 180000
還要
echo 180000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
Maximal number of timewait sockets held by system simultaneously. If this number is exceeded TIME_WAIT socket is immediately destroyed and warning is printed. This limit exists only to prevent simple DoS attacks, you must not lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value (180000).
所以當你設小的時候呢,/var/log/messages就會出現一堆"kernel: TCP: time wait bucket table overflow",所以default值千萬別亂改,如果你的程式會有狠大的traffic
怎麼改回來呢?
在/etc/sysctl.conf加這行
net.ipv4.tcp_max_tw_buckets = 180000
還要
echo 180000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
星期二, 12月 29, 2009
[Linux]linux記憶體被吃光
相信很多人遇到用top看明明就沒有程式用記憶體很兇,但是記憶體還是被用光了
怎麼辦呢?
http://blog.chinaunix.net/u/27173/showart_467689.html
http://blog.yesican.tw/?p=912
其實就是linux為了提高disk IO的存取效率,所以有cache pagecache, dentries and inodes
怎麼free呢
#free
#sync
#echo 3 > /proc/sys/vm/drop_caches
#echo 0 > /proc/sys/vm/drop_caches
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
-----------------------------------------------------------------
Update
http://ssorc.tw/rewrite.php/read-599.html
這篇對於linux memory usage有更詳細的說明
節錄buffer and cache的說明~~~^^
Free中的buffer和cache︰(它們都是佔用內存)︰
buffer : 作為buffer cache的內存,是塊設備的讀寫緩沖區
cache: 作為page cache的內存, 文件系統的cache
如果 cache 的值很大,說明cache住的文件數很多。如果頻繁訪問到的文件都能被cache住,那麼磁盤的讀IO bi會非常小。
Read more: http://ssorc.tw/rewrite.php/read-599.html#ixzz0gbxRjPrV
------------------------------------------------------------------------
[Update]
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
但這一篇就在說明ps很不準,別看ps的memory usage
怎麼辦呢?
http://blog.chinaunix.net/u/27173/showart_467689.html
http://blog.yesican.tw/?p=912
其實就是linux為了提高disk IO的存取效率,所以有cache pagecache, dentries and inodes
怎麼free呢
#free
#sync
#echo 3 > /proc/sys/vm/drop_caches
#echo 0 > /proc/sys/vm/drop_caches
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
-----------------------------------------------------------------
Update
http://ssorc.tw/rewrite.php/read-599.html
這篇對於linux memory usage有更詳細的說明
節錄buffer and cache的說明~~~^^
Free中的buffer和cache︰(它們都是佔用內存)︰
buffer : 作為buffer cache的內存,是塊設備的讀寫緩沖區
cache: 作為page cache的內存, 文件系統的cache
如果 cache 的值很大,說明cache住的文件數很多。如果頻繁訪問到的文件都能被cache住,那麼磁盤的讀IO bi會非常小。
Read more: http://ssorc.tw/rewrite.php/read-599.html#ixzz0gbxRjPrV
------------------------------------------------------------------------
[Update]
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
但這一篇就在說明ps很不準,別看ps的memory usage
星期一, 12月 21, 2009
[Linux] logrotate setup and test
如果要利用logrotate幫你rotate log,請在加入一個file在/etc/logrotate.d/下面
# vim /etc/logrotate.d/aaa
content:
/var/log/aaa {
daily
ifempty
rotate 7
}
# service syslog restart
如何知道設定對不對,請打
# logrotate /etc/logrotate.conf
至於有那些可以設定,請man logrotate嚕
# vim /etc/logrotate.d/aaa
content:
/var/log/aaa {
daily
ifempty
rotate 7
}
# service syslog restart
如何知道設定對不對,請打
# logrotate /etc/logrotate.conf
至於有那些可以設定,請man logrotate嚕
訂閱:
文章 (Atom)