Monitor Linux system logs in real time, you can know the startup time of the system, etc.!

zhaozj2021-02-16  163

Date: 2004/08/07 Author: zcatlinux Source: zclinux

The following scripts are mainly to monitor the logs generated by the system, as long as there are also logging contents in the log, and generate the desired log files in real time, to keep check! Note: If the log function of the system has been destroyed, this method is invalid. Vi Run_log.sh #! / bin / bash

While [true]; do date = `DATE % Y% M% D` Tail -f / var / log / message | egrep" (syslogd 1.4.1: restart | login on) >> / home / log / run_syslog . $ Date Sleep 2 Done

CHMOD u x run_log.sh

-------------------------------------------------- -----------------------

Tail -f / var / log / message | egrep ">> / home / log / run_syslog. $ DATE in the above scripts, (syslogd 1.4.1: restart | login on ), Can add content existing in the monitoring system log file as required, different contents in the middle of the way ------------------------ --------------------------------------------------

Also Begm Be sure to join this script file into the system boot file, that is, let the system start this script to start the monitoring effect, join the method as follows: vi /etc/rc.d/rc.local# !/bin/sh # # This script will be executed * after * all the other init scripts. # You can put your it atitization stuff in Here if you don't # Want to do the full sys v style init stuff. Touch / var / lock / subsysys / local sh/usr/run_log.sh Save Exit, let the system restart, use ps -ef | grep run_log.sh, check if this script has been started, or view / home / log / under run_syslog.2004- 08-07 This file. After this success, I will know when the server is restarted later, and some people have logged in the server system. ^ _ ^. . This is not to do more things to do more, don't know when the system has been logged in by Hacker, I don't know. As long as you often go to view the generated log files.

转载请注明原文地址:https://www.9cbs.com/read-8265.html

New Post(0)