Shell 通用日志函数

为了方便调试,写了一个通用的日志函数,实现功能: 设定日志级别,实现可以输出不同级别的日志信息 日志格式类似为:[日志级别] 时间 funcname:函数名 [lineno:行号] 日志信息 不同级别,设定不同颜色 代码: function log { local text;local logtype logfile=/var/log/mylog/mylog.log logtype=$1 text=$2 message="`date +'%F %H:%M:%S'` $1 line:$LINENO $2" case $logtype in error) echo -e "\033[31m${message}\033[0m" | tee -a $logfile;; info) echo...

Shell监控jmap和jstack信息

#!bin/sh if [ $# -lt 1 ] ; then echo "please input execute count parameter" exit fi jmap_dir=/mnt/ray/jmap/ jstack_dir=/mnt/ray/jstack/ count=$1 i=1 mkdir /mnt/ray/jmap/ mkdir /mnt/ray/jstack/ while(($i<$count)) do for port in $(jps|grep CoarseGrainedExecutorBackend|awk '{print $1}') do filename=`date '+%Y-%m-%d_%H:%M:%S'` sudo -u hive /usr/java/latest/bin/jmap -histo $port > $jmap_dir$filename"_"$port.jmap sudo -u hive /usr/java/latest/bin/jstack...

Linux磁盘批量分区和挂载

Format #!/bin/sh #DEVICE_LIST="" DEVICE_LIST="/dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh" for DEVICE in $DEVICE_LIST do echo "+++++create partition for $DEVICE......" parted -s $DEVICE mklabel gpt mkpart gpt2t ext2 0% 100% PARTITION="$DEVICE""1" echo "+++++formatting $PARTITION......" mkfs.ext4 -T largefile $PARTITION done Mount #!/bin/sh #backup /etc/fstab cp /etc/fstab /etc/fstab.bak PARTITION_LIST="sdb1 sdd1 sde1 sdf1 sdg1 sdh1" for PARTITION in $PARTITION_LIST do ...