BASH Snippet
自動找出mediaserver的pid,並印meminfo和該pid的memory map
while [ true ]
do
top -n 1 | grep mediaserver
cat /proc/meminfo
cat /proc/`ps | grep -i mediaserver | awk {'print $2'}`/maps
echo ' '
echo ' '
done
顯示指定檔案的size和md5
#!/bin/bash
if [ "$#" -lt 1 ] || ! [ -f "$1" ]
then
echo 'should assian a valid file';
exit -1;
fi
file=$1
if [ -f "$file" ]
then
fsize=`ls -l $file | awk {'print $5'}`;
md5val=`md5sum $file | awk {'print $1'}`;
echo "filename=$file size=$fsize md5sum=$md5val";
else
echo "$file not found."
exit -1;
fi
#!/bin/bash
(IFS=':'
idx=0
for p in $PATH;
do
echo "PATH[$idx]=$p"
idx=$((idx+1))
done)
#!/bin/bash
echo "$(date +%y%m%d)"
印出目前主機的login使用者
w
w -h # ignore table header
w -s # short forma
t
w # show information
who
who -u # show login users
who -b # server last boot time
echo $SSH_CLIENT | awk '{ print $1}'
w $USER | awk '{print $3}' | xargs | awk '{print $3}'
留言