Use the Record Tool (history, screen, script) in Linux
Source: Internet
Author: User
In Linux, the record tool (history, screen, script) is usually used to record only some time and overhead at work, but not some processes, this article will introduce some record methods in Linux: 1. Historyenv is the most common record method. we can use the record tools (history, screen, script) in Linux) usually, people only record some time and overhead at work, but not some processes. This article will introduce some record methods in Linux: i. The most common record method of History/env. we can save history to a file, so we can probably know how you operate it through this file. History> session_cmd_record to save your current history information, or you can use HISTFILE = filenmae bash (dedicated to bash) to open a bash and save records in a special file: HISTFILE = session2.log bash it is also useful to put the log into another file and set HISTIGNORE to ignore unimportant commands, for example, ignoring unimportant commands such as pwd and date. Export HISTIGNORE = "ls: pwd: who" ignores irrelevant commands. export HISTSIZE = 10000 sets the maximum size of the history file. in the project, you also need to record some environment information and save it, there may often be people who do not save the environment information, so you will no longer be able to know the original configuration after three years of viewing this program, and thus cannot run normally. In this case, it may take three weeks for the user to change the code to find out why the system cannot run normally. Therefore, it is important to record environment information. For example, we can record this: env> env_record records your environment settings. note: env does not record all environment variables. 2. screen Screen can be seen as the command line interface version of the window manager. It provides a unified interface for managing multiple sessions and corresponding functions. In the article "use screen shared sessions", I introduced how to use screen to implement shared sessions. it is better to use screen to share a terminal window with multiple computers. In linux Tips: use screen to manage your remote sessions, there are some high-end applications of screen on window management. However, this article introduces the record. screen is mentioned because it also has the record function. you can use Ctrl + H to enable or disable the record, or use Ctrl + h to record. You can also use "screen-L" to record the entire session. after using the screen-L command, the listener will enter a record state, and all the work done in this state will be saved, until you exit with exit or Ctrl + D, the record will be saved in screenlog.0 by default (if screenlog.0 has been recorded, name it screenlog.1 ......). Screen-L is more effective for saving error messages or simply recording how to build programs. Note: If you do not need to modify the screenlog.0 file under "screen-L", you will not be so smart. 3. Recording with script if you have not installed the script, you need "apt-get install bsdutils" to install the script first. The following is a demonstration: long @ zhouyl :~ $ Cd/tmp/long @ zhouyl:/tmp $ script-t 2> time data is now recorded. let's test it. for example, we use date, time, alternatively, use vim to open a file, make some modifications, and save and exit. Now we use exit to exit the script, and the system will prompt: Script done, file is data now we will get two files, one data and one time. now we can use: long @ zhouyl: /tmp $ scriptreplay-t time data to replay the previous script session, which is a good way to save the work, we can use scriptreplay to play back the previously saved records, and we will clearly see how we operated previously (more intuitive than history, which is really worth a try ).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service