#!/bin/sh dir="/log" [ ! -d ${dir} ] && mkdir ${dir} time=`TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S` while true do [ ! -d ${dir} ] && mkdir ${dir} t=`TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S` runtop=`top -n 1 | head -n 5` pid=`top -n 1 | grep "xx" | grep -v "grep" | awk -F' ' '{print $1}' | sed s/[[:space:]]//g` fdnum=`ls -lR /proc/$pid/fd | grep "^l" | wc -l` echo -e "fd use num: $fdnum *** $runtop" >> "${dir}/temp$(TZ=UTC-8 date +%Y-%m-%d).txt" sleep 5 done
标签:-%,UTC,grep,top,写入,保存,TZ,dir From: https://www.cnblogs.com/xiaojiaocx/p/16992893.html