Historial de Linux de todos los comandos ejecutados durante todo el día, todos los días
Frecuentes
Visto 227 equipos
0
I need to have list of all commands with time when command executed that linux user has fired during whole day, every day.
For that i created a shell script in which i used history command and scheduled in crontab. But its not giving any output.
Can any one please help me on this ? Also suggest if any other better way to do it with code.
Gracias de antemano.
#!/bin/bash
dt1=$(TZ=GMT+18:30: date +%d/%m/%y)
dt=$(TZ=GMT+18:30: date +%d-%m-%y)
mkdir /tmp/comm_hist/$dt
chmod 777 /tmp/comm_hist/$dt
for user in `cat /etc/passwd | grep "bash" | cut -d":" -f1`
do
su - $user <<EOF
HISTFILE=~/.bash_history
set -o history
#history | grep "$dt1" > /tmp/comm_hist/$dt/$user.txt
history > /tmp/comm_hist/$dt/$user.txt
EOF
done
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas linux or haz tu propia pregunta.
you're not going to provide the shell script you wrote? - thescientist
The ancient gods I delegate to in order to divinate scripts are getting tired, they would like you to post it in your question instead. - Frédéric Hamidi
Seems like a bit futile attempt. Whatever you do with shell command history will never show all commands executed, as shell history logging can be easily disabled, circumvented or not used at all. You might need to look into some kernel-level solutions for this kind of auditing. - Yirkha
también puedes usar
script
when running a new shell to log all the session. Maybe a bit violent though. - AifSounds like you probably need to research the process accounting capabilities of Linux... - twalberg