In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use the logrotate command of Linux. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Linux common commands logrotate commands are used to rotate, compress, and delete system logs, or you can send logs to a specified mailbox.
Logrotate system logs are rotated, compressed, and deleted
Supplementary note: using the logrotate instruction, you can easily manage the record files generated by the system. Each record file can be set to be processed daily, weekly or monthly, or immediately if the file is too large. You must edit and specify the configuration file yourself, and the default configuration file is stored in the / etc/logrotate.conf file.
Syntax logrotate (option) (parameter) option -? Or-- help: online help;-d or-- debug: show the execution process of the instruction in detail to facilitate troubleshooting or understand the execution of the program;-f or-- force: forcibly start the record file maintenance operation, even if the logrotate instruction does not think it is necessary;-s or-- state=: use the specified state file;-v or-- version: show the instruction execution process;-usage: show the basic usage of the instruction. Parameter profile: specifies the configuration file of the lograote directive.
Instance crontab periodically invokes the logrotate command to configure the use of the
Logrotate's configuration file / etc/logrotate.conf definition references some custom log configurations in the / etc/logrotate.d directory
Create a file with any suffix in the / etc/logrotate.d directory, and you can rotate the log using the
/ tmp/log/log.txt {copytruncate daily rotate 30 missingok ifempty compress noolddir} this configuration file represents a rotational compression of the / tmp/log/log.txt file
Compress uses gzip compression to dump logs nocompress does not do gzip compression processing copytruncate is used to backup and truncate the current log files that are still open. It is a way to copy and then empty. There is a time difference between copy and emptying, and some log data may be lost. Nocopytruncate backup log files but do not truncate the attributes specified when create mode owner group rotation creates new files, such as create 0777 nobody nobody nocreate does not establish new log files delaycompress and compress are used together, the dumped log files will not be compressed until the next dump nodelaycompress overwrite delaycompress option, dump also compress missingok if the log is lost Do not report an error the error message when scrolling the next log errors address storage is sent to the specified Email address ifempty to rotate even if the log file is empty, which is the default option for logrotate. When notifempty log file is empty, no rotation is performed mail address sends the dumped log file to the specified E-mail address nomail dump does not send log file olddir directory dump log file is placed in the specified directory The log files after noolddir dump and the current log files must be placed in the same directory as the current log files. Sharedscripts runs the postrotate script, which is used to execute the script once all logs are rotated. If this is not configured, then each log rotation will execute the instructions that the script prerotate needs to execute before the logrotate dump, such as modifying the properties of the file; it must be a separate line of instructions that postrotate needs to execute after the logrotate dump, such as kill-HUP a service! Must be a separate line daily specify dump cycle daily weekly specify dump cycle weekly monthly specify dump cycle monthly rotate count specify number of dumps before log file deletion, 0 means no backup 5 means to keep 5 backup dateext using the current date as the naming format dateformat.% s with dateext, which appears immediately after the next line. The file name after the cut of the definition file must be used with dateext. Only four parameters, Y% m% d% s, size (or minsize) log-size log files, are supported to dump notes when they reach the specified size. Create files with arbitrary suffixes in the / etc/logrotate.d directory.
/ tmp/log/log* {copytruncate daily rotate 30 missingok ifempty compress noolddir} in this case, the rotated log will be rotated again, because the filename after rotation is also beginning with log.
These are all the contents of this article entitled "how to use Linux's logrotate commands". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.