Linux Systems Administration SysAdmin Bash shell logging script exec bash history logs logger
$30-250 USD
Selesai
Disiarkan lebih dari 10 tahun yang lalu
$30-250 USD
Dibayar semasa penghantaran
I need a couple of Linux systems admin tweaks....
First what's the best way to add timestamp to Linux prompt and to what file .profile bashprofile /etc globally etc bla bla.
Second I'm sick and tired of bash_history missing many commands or having some deleted due to crashed/frozen putty sessions.
What's best way to ensure I NEVER lose any bash_history, that I record ALL without any limit to file size, or if can't make me .bash_history_datestamp_archive or something like? [login to view URL]
The other thing is I want LOGGING of my linux shell if I am NOT using putty, but similar to how putty has option to LOG the entire session.
I hear there's is the "SCRIPT" command for this but problem is it only works for me if i start a linux shell and then myself type script command, but I wasn't able to automate it. Where can I add this so that a LOGGING file named with file date/timestamp starts AUTOMATICALLY every time i start a session? I heard other solution is using "exec" command ie [login to view URL]
like exec > >(tee -a [login to view URL])
Anyway this logging shouldn't corrupt the file if i use vi for editing in my session etc, but it doesn't have to properly log the vi text, i know even putty messes up logging the vi editing. But everything else it should log well, commands, output from commands, out put form more or cat etc...
And it should save each of the shell 'sessions' to a date/timestamped file. Again I don't want to myself run the command to start logging, i want it in /etc/profile or /home/user/.bashrc or user/.profile etc so that logging starts whenever a SHELL is run/opened ...
Besides "Script" command or "Exec" you should also look into TTY SNOOPing or starting a "SCREEN" session and then logging it with it somehow (screen supports screen -x snooping and logging to i think?) , tty watcher , sniff etc. Main thing I don't want to use complex 3rd party code that can't be trusted so solutions based on existing tools inside linux distributions is preferred. (There's ttyrec and others also)
Here's some more links i dug up quickly I don't have time to test and find out the best methods to achieve what i want, i'm looking for someone who's already been there done that:
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
If you don't figure out WHICH is best just give me Several solutions that are AUTOMATED like i want, ie i start a shell session i don't have to remember to start logging or to exit things etc...should do it for me and i should have resulting datestamped logfiles.
Hello!
Yes, all that you have listed can be used. What and how to use depends only on the goals.
For example, If you want to record only the commands and their output, the most easy way - script.
.bashrc:
if [ -z "${PPID}" ]; then
PPID=$(ps -p $$ -o ppid=);
fi
PCOMMAND=$(ps -p ${PPID} -o command=);
if ! expr "${PCOMMAND}" : "^\(/usr/bin/script\|script\)" 2>&1 >/dev/null; then
script -f ${HOME}/$(date +%s).log;
fi
Thanks!
$30 USD dalam 1 hari
5.0 (2 ulasan)
1.3
1.3
3 pekerja bebas membida secara purata $109 USD untuk pekerjaan ini