Centos 7 Implementation of recurring tasks, log rotation, filtering, and core compression

Source: Internet
Author: User
Tags cron script

Centos7 periodic task log rotation, filtering, and core compression implementations


Example of implementation of Cron script and its invocation script in 1.centos7


[Email protected]cron.d]# pwd

/etc/cron.d

[Email protected]cron.d]# cat syslog

#Run Mysys Activity Accounting tool every minutes

*/5* * * * root/usr/sbin/mysyslog.sh 2>&1 >>/var/log/mysys.log

#0 * * * * ROOT/USR/LIB64/SA/SA1 6 &

#Generate a daily summary of process accounting at 23:53

*/5* * * * root/usr/sbin/ipmilog.sh

#5323 * * * root/usr/lib64/sa/sa2-a



2. Implementing log rotation and its related scripts

[Email protected]logrotate.d]# pwd

/etc/logrotate.d

[Email protected]logrotate.d]# cat Selmon

/var/log/ipmi.log{

Weekly

Copytruncate

Compress

Missingok

Notifempty

rotate200

}

[Email protected]logrotate.d]# cat Mysysmon

/var/log/mysys.log{

#weekly

Daily

Copytruncate

Compress

Dateext

create644 root root

Missingok

Notifempty

Rotate10

}


[Email protected]logrotate.d]# cat Smhmon

/var/sysdbase/eventlog.txt/var/sysdbase/eventlog {

Weekly

Copytruncate

Ccompress

Dateext

create644 root root

Missingok

Notifempty

rotate198

}


Updates to the 3.rsyslog.conf rule


Add support for Ceph-fuse logs:

: Syslogtag,contains, "Ceph-fuse"/var/log/lsd/ceph-fuse.log


Add output to the application that needs to crawl the staging log:

#:syslogtag, contains, "Gluser-fire"/var/log/log.txt

#action (type= "Omfile" file= "/var/log/log.txt")

If$programname = = ' Gluser-fire ' then {

If$msg contains ' in print level 0 ' then

Action (type= "Omfile" file= "/var/log/log-level0.txt")

If$msg contains ' in print Level 1 ' Then

Action (type= "Omfile" file= "/var/log/log-level1.txt")

If$msg contains ' in print Level 2 ' then

Action (type= "Omfile" file= "/var/log/log-level2.txt")

If$msg contains ' in print Level 3 ' then

Action (type= "Omfile" file= "/var/log/log-level3.txt")

If$msg contains ' in print Level 4 ' Then

Action (type= "Omfile" file= "/var/log/log-level4.txt")

If$msg contains ' in print Level 5 ' Then

Action (type= "Omfile" file= "/var/log/log-level5.txt")

If$msg contains ' in print Level 6 ' Then

Action (type= "Omfile" file= "/var/log/log-level6.txt")

If$msg contains ' in print Level 7 ' Then

Action (type= "Omfile" file= "/var/log/log-level7.txt")

}


4. Modify the way the kernel panic to generate the core

1) Enter ulimit-c in terminal if the result is 0, the system does not generate coredumpwhen the program crashes.

2) Use the ulimit-c Unlimited command to turn on the coredump feature and not limit the size of the generated coredump file. If you need a limit, add a numeric limit. ulimit-c 1024x768


3) refer to the following command to achieve core compression:

Modify/proc/sys/kernel/core_pattern:

[[Email protected]~]# cat/usr/sbin/core_compresser

#!/bin/bash

Execgzip->/var/core/app/core-$1-$2-$3.gz

#!/bin/bash

Execgzip->/var/core/app/core-$1-$2-$3.gz

[[Email protected]~]# Cat/proc/sys/kernel/core_pattern

/var/core/app/core-%e-%p-%t

[Email protected]~]# echo "|/usr/sbin/core_compresser%e%p%t" >/proc/sys/kernel/core_pattern

[[Email protected]~]# Cat/proc/sys/kernel/core_pattern

|/usr/sbin/core_compresser%e%p%t



This article is from the "Store Chef" blog, so be sure to keep this source http://xiamachao.blog.51cto.com/10580956/1882049

Centos 7 Implementation of recurring tasks, log rotation, filtering, and core compression

Related Article

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.