How do I keep logs of all the work done via terminal? For example, I want a record of all the work done on database via terminal.
How do I keep logs of all the work done via terminal? For example, I want a record of all the work done on database via terminal.
When you are ready to start recording a log file, type:
Now, until you stop the script, all input and output in the Terminal will be stored in screen.log. When you are done, just type:
Your screen.log file will stored in the local directory. If you want to redirect it, use an absolute pathname such as
~/screen.log
. This will do exactly what you are looking for.Source: Ubuntu Guide - How To Log Terminal Commands
You may want to try out Asciinema. In addition to just making a recording you get the ability to share it and embed the player on your blog, article or in a conference talk.
I have a better way to use syslog for logging every shell command this can be vary upon linux distribution but method will remain same
You need to follow some steps:
Step # 1 (Create Syslog service)
Step # 2 (Open bashrc and enter below command)
Ste # 3 (Restart Syslog Service)
Here is a log sample:
nhi will perfectly solve your problem. This tool automatically captures all potentially useful information about each executed command (as well as its output).
With
nhi
you can easily retrieve any shell session (or terminal output) in its entirety, or only commands that you are interested in, by using an advanced querying mechanism provided bynhi
.Note:
I am the creator of this tool. If you have questions, please feel free to ask.