Linux system management-system log function

Source: Internet
Author: User
1. system log:/var/log event log: records everything that occurs. many subsystems generate logs such as system and mail. web. dnsdebug has the most detailed recording levels: info, warn, error, and alert. these are event-level logs of different levels. syslog is used to record the current system...

 

1. system logs:

/Var/log

Event Log: records everything that happens

Many subsystems generate logs such

System, mail. web. dns

The most detailed debug record level

Info, warn, error, and alert are event-level logs.

Divided into different levels,

 

Syslog is used to record the logs generated on the current system

Two service processes syslogd, klogd, and suditd (some users or processes violate the logs generated by linux) constitute syslog

/Etc/syslog. conf their configuration files are here

 

Priority. priority. priority/var/log/somefile. log

Which or what levels of subsystems are there, and where their levels are defined

 

Once an emerg message appears in a system, the service will be suspended in the next second. the highest level of warning information and red warning will be triggered.

 

Priority. = priority

Which records only one specific log

 

The first entry indicates asynchronous writing.

 

* Represents any

 

Ls/etc/init. d | syslog

There is a syslog in init. d under etc.

If the script stops, two processes, kernel logger and sustem logger, will be stopped.

 

 

 

Operate on our host

Vim/etc/syslog. conf

Change device location to IP address

 

Operate on the master server

Vim etc/eysconfig/syslog

In this file, there is a SYSLOGD_OPTIONS system log option, followed by "-m 0-r" and then restart service susulog restart to accept the information logs of other servers.

 

 

Under/var/log/messager

Composed of four fields

Time when the first event was generated

Second related host

Third, which subsystem generates information

Fourth log content

The logger command can record the generated command here

 

 

 

 

 

 

2. periodic task plan:

It can be commands, scripts, and data backup scripts.

By default, emails are sent to administrators.

 

One-time application:

 

At: specifies a time point. it can be expressed by absolute time, time, or fuzzy time.

You can also use am pm to modify the time from month, day, month, and year to a specific time (from the moment to a certain time ).

 

The batch cannot be specified because it can be executed when the system is idle.

 

At now + 2 min

Ls/etc

Echo "how are you? "

CTRL + D submit

 

At-l view that the task data is executed

Atq = at-l

 

Mail the current host user accepts his/her own mail

Quit exit the email list

 

A task is scheduled to be canceled before execution.

At-r removes

At-r = atrm

 

Myat.txt

At-f myat.txt now + 7 days

List of periodically executed tasks

 

 

 

Periodic task plan:

Crond:

One is system periodic tasks:/etc/crontab can be viewed with cat

Seven Fields

 

One is the user's periodic task:/var/spool/cron/USERNAME

6 fields

 

Fraction Minute 0-59

Several points of Hour0-23

Days of Day of Month 1-31

Month 1-12

Day of week 0-7

 

Wildcard:

(*) All valid values in the corresponding value range

(,) Discrete value range: 1 and 31, 31 ****

(-) 08:01 1 8 *** 2-5 every day from Week 2 to Week 5

(/) Execute 0-59/2 *** every two minutes ****

 

 

 

How do users define their own cron:

Crontab

-U specifies a user

-E: define your own

 

Press crontab-e to open the vim editor immediately.

*/2 */bin/echo "howdy"

 

Crontab-r remove all plans

Crontab-e: Delete a row and then delete it separately.

 

Crontab-l check your crontab

 

We can also define others' crontab

 

 

Anacron is used to design PCs that often have hanging up. it is a supplement to crontab.

Effective promotion · execute unexecuted tasks after the next day

Chkconfig -- list anacron

Service anacron status

The configuration file is in the/etc/anacrontab

This file has only four fields

The first field indicates that if a task has not run once in at least one day in the past, it will run once 65 minutes after we start up ,,

Second Field Day

The third month

 

10 3 *** tar-jcf/backup/'date ready before f'.tar.bz2/etc '>/var/spool/cron

 

This article is from the "three-inch heaven" blog

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.