开发者

count execution of specific commands

开发者 https://www.devze.com 2023-03-05 07:41 出处:网络
How can I co开发者_StackOverflowunt how often a specific program / command is launched under linux?

How can I co开发者_StackOverflowunt how often a specific program / command is launched under linux?

Can I avoid a wrapper-shell-script ?

I need to count and measure my build cycle to convince management of better tools :-)


systemtap's fork tracer could be he answer.Just adjust it to your needs.


I'm not sure if an alias counts as a shell wrapper script ... if not, then something like the following will count the number of times the aliased command (ls in this case) is run. Create a file named ~/counter with a zero in it up front and this will increment it each time.

alias ls='awk "{print \$1+1}" ~/counter > ~/counter.new ; mv ~/counter.new ~/counter ; ls'


This commend line will prompt the most frequently used commands you type :

history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr

That produce (in my case) :

 104 reset
 89 ll
 78 cd
 52 sudo
 45 ssh
 45 ./unittest.sh
 44 ps
 38 python
 37 man
 29 ls
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号