728x90 AdSpace

Sunday, 3 September 2017

logrotate Linux Command

logrotate

logrotate [options] config_files
System administration command. Manipulate logfiles according to commands given in config_files.

Options

-d, --debug
Debug mode. No changes will be made to logfiles.

-f, --force
Force rotation of logfiles.

-h, --help
Describe options.

-m command, --mail command
Use the specified command to mail logfiles. The default command is /bin/mail -s.

-s file, --state file
Save state information in file. The default is /var/lib/logrotate.status.

--usage
Show syntax and options.

-v, --verbose
Describe what is being done and what logfiles are affected.

Configuration Commands

Logrotate directives may appear on their own or as part of logfile definitions—instructions for specific logfiles. You may use wildcards to specify those files. Enclose directives for logfile definitions in a beginning and ending curly brace. For example:

compress /var/log/messages { rotate 5 weekly }

compress
Compress old versions of logfiles with gzip.

compresscmd command
Use command to compress logfiles. Default is gzip.

compressext extension
Append filename extension to compressed files instead of the compress command's default.

compressoptions options
Specify options to pass to the compress command. Default for gzip is -9 for maximum compression.

copy
Copy logfile, but do not change the original.

copytruncate
Copy logfile, then truncate it in place. For use with programs whose logging cannot be temporarily halted.

create [permissions] [owner] [group]
After rotation, re-create logfile with the specified permissions, owner, and group. permissions must be in octal. If any of these parameters is missing, the logfile's original attributes will be used.

daily
Rotate logfiles every day.

delaycompress
Don't compress logfile until the next rotation.

endscript
End a postrotate or prerotate script.

extension extension
Give rotated logfiles the specified extension. Any compression extension will be appended to this.

firstaction
May only be used as part of a logfile definition. Begin a shell script to execute once if any files match. The script ends when the endscript directive is read.

ifempty
Rotate logfile even if it is empty. Overrides the default notifempty option.

include file
Read the file into current file. If file is a directory, read all files in that directory into the current file.

lastaction
May only be used as part of a logfile definition. Begin a shell script to execute once after rotating all matching files and running any postrotate script. The script ends when the endscript directive is read.

mail address
Mail any deleted logs to address.

mailfirst
When using the mail command, mail the newly rotated log instead of the one being deleted.

maillast
When using the mail command, mail the log that is about to expire. This is the default behavior.

missingok
Skip missing logfiles. Do not generate an error.

monthly
Rotate logfiles only the first time logrotate is run in a month.

nocompress
Override compress.

nocopy
Override copy.

nocopytruncate
Override copytruncate.

nocreate
Override create.

nodelaycompress
Override delaycompress.

nomail
Override mail.

nomissingok
Override missingok.

noolddir
Override olddir.

nosharedscipts
Override sharedscripts. Run prerotate and postrotate scripts for each log rotated. This is the default.

notifempty
Override ifempty.

olddir directory
Move logs into directory for rotation. directory must be on the same physical device as the original logfiles.

postrotate
May only be used as part of a logfile definition. Begin a shell script to apply after the logfile is rotated. The script ends when the endscript directive is read.

prerotate
May only be used as part of a logfile definition. Begin a shell script to apply before a logfile is rotated. The script ends when the endscript directive is read.

rotate number
The number of times to rotate a logfile before removing it.

size n[k|M]
Rotate logfile when it is greater than n bytes. n can optionally be followed by k for kilobytes or M for megabytes.

sharedscripts
Run prescript and postscript only once for the session.

start n
Use n as the starting number for rotated logs. Default is 0.

tabooext [+] extlist
Replace taboo extension list with the given extlist. If + is specified, add to existing list. The default list is .rpmorig .rpmsave ,v .swp .rpmnew ~.

weekly
Rotate logfiles if more than a week has passed since their last rotation.

uncompresscmd command
Use command to uncompress logfiles. Default is gunzip.
Annamalai Thangaraj

Annamalai is working as Technical Lead in Leading Telecom company with 5+ years experience in Identity and Access Management , Telecom and Networks, BigData, Java, Spring, Struts, Hibernate, AngularJS, and Enterprise Web Application Development.

Website: Java Tutorials Corner

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: logrotate Linux Command Rating: 5 Reviewed By: Annamalai Thangaraj