Operation Record of monitoring user under Linux

Source: Internet
Author: User

Want to know what the user has done after logging into the system, how to do?

Don't worry, Linux has a script tool that specifically records all input and output results in a terminal session and stores it in a specified file.

Let's see how to record it first!

1. Create Log storage Directory

# mkdir/opt/operation_log# chmod 777-r/opt/operation_log

2. Set up automatic recording after user login

# vi/etc/profile #末尾追加一下内容if [$UID-ge 500]; Then exec script-t 2>/opt/operation_log/$USER-$UID-' date +%f-%t '. Date-a-q-f/opt/operation_log/$USER-$UID-' date + %f-%t '. logfi# source/etc/profile #刷新生效

Parameter description:

-T: Record operation timing,2> The timing of the output to the specified file, using this time file for playback

-A: The output is appended to the file

-Q: Silent start

-F: Refresh output after each write

3. View the generated files

# ll/opt/operation_log/total 8-rw-rw-r--1 Test test 124 Jul 3 07:17 test-1001-2015-07-03-07:17:36.date-rw-rw-r--1 Test Test 167 Jul 3 07:17 Test-1001-2015-07-03-07:17:36.log

As you can see, the log format we define is generated separately.

When using log logs for a long time, with more or cat view is more laborious, then there is a corresponding tool called Scriptrelay, by combining script output of the timing file, can be automatically played.

4. Operation Record Replay

# Scriptreplay Test-1001-2015-07-03-07:17:36.date Test-1001-2015-07-03-07:17:36.log

Isn't it much easier!


If you simply record this operation command, you can run it directly:

# Script Test

Will switch to script, wait until you finish the command, enter exit to exit, and then view the test file.


This article is from the "Li Zhenliang Technology Blog" blog, make sure to keep this source http://lizhenliang.blog.51cto.com/7876557/1670563

Operation Record of monitoring user under Linux

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.