Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ppabc committed Jun 6, 2016
1 parent 7699663 commit 90b8740
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ansible/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
ansible all -m ping
ansible webservers -m ping

##重启webservers组所有SSH服务.
ansible webservers -m service -a "name=sshd state=restarted"

##command: 执行远程主机SHELL命令:
ansible webservers -m command -a "free -m"
Expand Down Expand Up @@ -88,6 +86,8 @@ ansible all -m cron -a 'name="custom job" minute=*/3 hour=* day=* month=* weekda
ansible webservers -m service -a "name=crond state=stopped"
ansible webservers -m service -a "name=crond state=restarted"
ansible webservers -m service -a "name=crond state=reloaded"
##重启webservers组所有SSH服务.
ansible webservers -m service -a "name=sshd state=restarted"

##user服务模块
##远程主机系统用户管理
Expand Down
3 changes: 2 additions & 1 deletion shell/history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export PROMPT_COMMAND="history -a"
export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "

##记录history历史命令 时间 IP等
##export HISTTIMEFORMAT="{\"TIME\":\"%F %T\",\"HOSTNAME\":\"\$HOSTNAME\",\"LI\":\"\$(who -u am i 2>/dev/null| awk '{print \$NF}'|sed -e 's/[()]//g')\",\"LU\":\"\$(who am i|awk '{print \$1}')\",\"NU\":\"\${USER}\",\"CMD\":\""
cat >>/etc/bashrc<<EOF
HISTDIR='/var/log/command.log'
if [ ! -f \$HISTDIR ];then
touch \$HISTDIR
chmod 666 \$HISTDIR
fi
export HISTTIMEFORMAT="{\"TIME\":\"%F %T\",\"HOSTNAME\":\"\$HOSTNAME\",\"LI\":\"\$(who -u am i 2>/dev/null| awk '{print \$NF}'|sed -e 's/[()]//g')\",\"LU\":\"\$(who am i|awk '{print \$1}')\",\"NU\":\"\${USER}\",\"CMD\":\""
export HISTTIMEFORMAT="{\"TIME\":\"%F %T\",\"IP\":\"\$(ip a | grep -E '192.168|172' | head -1 | awk '{print$2}' | cut -d/ -f1)\",\"LI\":\"\$(who -u am i 2>/dev/null| awk '{print \$NF}'|sed -e 's/[()]//g')\",\"LU\":\"\$(who am i|awk '{print \$1}')\",\"NU\":\"\${USER}\",\"CMD\":\""
export PROMPT_COMMAND='history 1|tail -1|sed "s/^[ ]\+[0-9]\+ //"|sed "s/$/\"}/">> /var/log/command.log'
EOF

Expand Down

0 comments on commit 90b8740

Please sign in to comment.