Log rotation is especially useful for log files with fixed file names, such as MySQL error log, regular query log, slow query log, and so on. Linux system has a very easy to use according to Logratate can achieve automatic rotation, this article describes its principle and usage.
By default, Logrotate is deployed as a daily cron job, and you can find a configuration file named Logrotate in the directory/et
Tags: how to record file Many people ask how to know when the system will perform log storage and rollback, view the details of cron. daily, and view the scripts in logroate: #! /Bin/sh /Usr/sbin/logrotate/etc/logrotate. conf Exitvalue = $? If [$ exitvalue! = 0]; then /Usr/bin/logger-T logrotate "alert exited abnormally with [$ exitvalue]" Else /Usr/bin/
Logrotate log segmentation Configuration:
# Cat/etc/logrotate. d/nginx
/Data/nginx_logs/*. access_log # directory of nginx logs
{
Nocompress # do not perform dumping compression on Log Files
Daily # specify the dump cycle as daily
Copytruncate # used to back up and cut off the current log file that is still being opened
Create # create a new Log File
Ifempty # dump even an empty file
Olddir/data/nginx_logs/
Services on Linux server generally last long, so that the log files of services become larger over time, and if the log is poorly handled, it may even fill the disk. Fortunately found the Logrotate this program to deal with. Here is the installation configuration process zypperin-ylogrotate# Although Logrotate is run by cron cat/etc/cron.daily/logrotate#!/bin/sh/
Use logrotate to poll nginx and Apache Log document directories [Hide]
Configure nginx
Configure Apache
Using logrotate to poll logs is convenient and easy to configure. Configure nginx 1. Create the/etc/logrotate. d/nginx file.
VI/etc/logrotate. d/nginx
2. Write the following co
The understanding of the Logrotate operating mechanism is as follows:1, scheduled execution by Cron, script location/etc/cron.daily/logrotate2, logrotate script default profile/etc/logrotate.conf3, cron execution logrotate time not found the exact time currently (Times this self-defined)The test found that due to the rotation log date can only be the current date
Using logrotate to delete and compress logs logrotate is a built-in scheduled execution tool in linux, started and configured by cron. You can use this tool to manage logs. For example, you can use the following configuration to manage tomcat logs to avoid excessive directories: Java code/etc/logr...
Using logrotate to delete and compress logs
I,
Crontab routine check: If it is self-developedProgramTo open the file, you need to change the current working directory by absolute path or chdir.
Use getcwd to obtain the current working directory.
Ii. log rolling
Run the following command first:
[Root @ local cron. daily] #/usr/sbin/logrotate-F/etc/logrotate. confError: Error accessing/var/log/conman: no such file or directory
Error: conman: 5
Using the logrotate command allows you to easily manage the records generated by the system. It provides automatic replacement, compression, deletion, and mailing of record files. Each record file can be set to be processed every day, every week, or every month, and can be processed immediately when the file is too large. You must edit the configuration file by yourself. The default configuration file is stored in the/etc directory, and the file name
Tags: mysqlDepending on your needs, you can make a day-to-days dump of the MySQL-related log files (error logs, common query log files, and slow query log files) and keep only the backup files for a specified number of days, as an example:1), install Crond service (if yum install logrotate crontabsis not installed)Rpm-qa | grep crontabsYum Install CrontabsChkconfig Crond--list #如果未设置为自动重启这执行如下命令修改Chkconfig Crond onService Crond Restart2), create the M
1. Download LogrotateInstallation in Fedora and CentOSInstall logrotate crontabsOn Debian and UbuntuInstall logrotate cron2. Create a log filecd/var/log/Touchfilefile. log3. Create a File.log profile to addvim/etc/logrotate.d/File/vsr/log/file.log{Monthly log files per month round daily daily weakly yealyRotate 5 Stores 5 archived logs, the longest automatic deletion for the six
One
Crontab routine Check: If you are developing your own program, opening the file requires an absolute path or chdir to change the current working directory.
Use GETCWD to get the current working directory.
Second, log scrolling
Use the Execute command first:
[Root@local cron.daily]#/usr/sbin/logrotate-f/etc/logrotate.confError:error accessing/var/log/conman:no such file or directory
Error:conman:5 Glob failed for/var/log/conman/*
If the
Recently found in a server MySQL audit (http://jim123.blog.51cto.com/4763600/1955487) plug-in log no data, just started to think that is configured to the problem in the database check to see that there is no problem, Later found in the MySQL audit specified file path issued by the existing rotation log, the preliminary analysis is in the use of the system logrotate (http://jim123.blog.51cto.com/4763600/1880582) to do the log rotation to/etc/ LOGROTAT
Detailed Introduction http://blog.csdn.net/hepeng597/article/details/7768615Reference http://www.linuxidc.com/Linux/2011-04/34116.htm1 For example we want to cut Nginx log, first we enter/etc/logrotate.d/this directory, and then build nginx this fileVI Nginx/data/wwwlogs/*nginx.log {# #日志所在的目录dailyrotate 5missingokdateextcompressnotifemptysharedscriptspostrotate [-E/ Var/run/nginx.pid] kill-usr1 ' cat/var/run/nginx.pid ' Endscript}Parameter description:Monthly specify a dump cycle of monthlyDai
Believe that the RSYSLOGD logrotate transfer cutting log students, will find the log after the file, will appear inaccurate date problem
For example: The June 21-generated log was transferred to the June 22 document for no reason, and the date was one day ahead of schedule.
Or even if the 21st log is transferred to the number 21st file, when you open but found that there are 20th of the contents.
After a few days of verification, finally found that t
Virtualmin occurs when checking to verify that the error is present logrotate configuration is not valid:Error:stat Of/var/log/cron failed:no such file or directory
1. Main reasons
Log file rotation feature restricted
This is due to the syslog daemon not running. Check If the service is running and restart. Your server may have syslogd daemon on rsyslogd depending on Your OS.
2. Solutions
Let's look at the status first.
/etc/init.d/rsyslog statu
04. Run the kvm command line in ubuntu to install 64-bit ubuntu and report "Couldn't find hvm kernel for Ubuntu tree.", kvmhvm
1. The configuration of virt-install used for ubuntu installation:
virt-install \--name test4 \--ram 1024 \--disk path=/data/01_ubuntu/ubuntu4.img,size=6 \--vcpus 1 \--hvm \--os-type linux \--n
1. Configuration of the Virt-install used when installing Ubuntu:Virt-install \\1024x768 \path=/data/01_ubuntu/ubuntu4.img,size=6 \1 \ \--os-type linux \--network network=default \\--console Pty, target_type=serial \/data/00_osfile/ubuntu-16.04.1-server-amd64.iso \--extra-args ' Console=TTYS0,115200N8 serial 'The error is as follows:ERROR couldn ' t find HVM kernel for Ubuntu tree. not appear to has been
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.