Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ppabc committed May 20, 2018
1 parent 6370ae7 commit a53051a
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
72 changes: 72 additions & 0 deletions shell/backup/accountlog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 网上流传的简单记录操作的脚本
#vi /etc/profile.d/accountlog.sh
#chmod +x /etc/profile.d/accountlog.sh
#vi /etc/profile
#HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
historyLog(){

logDir=/data/accountlog

dateStamp=`date +"[%F %T]"`

dateDir="`date +%Y`/`date +%m`/`date +%d`"

curHistory=`history 1`

user=`/usr/bin/whoami`

realUserInfor=`/usr/bin/who -u am i|awk '{print $1,$2,$3"~"$4,$7}'`



if [ ! -e $logDir ];then

mkdir -p $logDir

chmod 777 $logDir

fi



logDateDir=$logDir/$dateDir

if [ ! -e $logDateDir ];then

mkdir -p $logDateDir

chmod -R 777 $logDir 2>/dev/null

fi



accountLogDir=$logDateDir/${user:=`hostname`}

if [ ! -e $accountLogDir ];then

mkdir -p $accountLogDir

#chmod 777 $accountLogDir

fi



accountLogName=${user:=`hostname`}.his

accountLog=$accountLogDir/$accountLogName

if [ ! -e "$accountLog" ];then

touch $accountLog

#chmod 777 $accountLog

fi

echo "$realUserInfor $dateStamp =>$curHistory" >>$accountLog

}

export PROMPT_COMMAND=historyLog
9 changes: 9 additions & 0 deletions shell/sed/sed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
##robert yu
##centos 6和centos 7

##查文件从32994到34871行内容
sed -n '32994,34871p' config_file

##删除文件从32994到34871行内容
sed '32994,34871 d' config_file

##替换文件中performance_schema改为performance_schema_bak
sed -i "s/performance_schema/performance_schema_bak/g" config_file

##sed去除注释行
sed -i -c -e '/^#/d' config_file

Expand Down

0 comments on commit a53051a

Please sign in to comment.