Created
May 3, 2013 06:45
-
-
Save perfectfoolish/5507573 to your computer and use it in GitHub Desktop.
record command of every user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PS1="`whoami`@`hostname`:"'[$PWD]' | |
history | |
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` | |
if [ "$USER_IP" = "" ] | |
then | |
USER_IP=`hostname` | |
fi | |
if [ ! -d /tmp/history ] | |
then | |
mkdir /tmp/history | |
chmod 777 /tmp/history | |
fi | |
if [ ! -d /tmp/history/${LOGNAME} ] | |
then | |
mkdir /tmp/history/${LOGNAME} | |
chmod 300 /tmp/history/${LOGNAME} | |
fi | |
export HISTSIZE=4096 | |
DT=`date +"%Y%m%d_%H%M%S"` | |
export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP}.history.$DT" | |
chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment