logrotate.8 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. .TH LOGROTATE 8 "3.15.1" "Linux" "System Administrator's Manual"
  2. .SH NAME
  3. logrotate \(hy rotates, compresses, and mails system logs
  4. .SH SYNOPSIS
  5. \fBlogrotate\fR
  6. \fR[\fB\-\-force\fR]
  7. \fR[\fB\-\-debug\fR]
  8. \fR[\fB\-\-state\fR \fIfile\fR]
  9. \fR[\fB\-\-verbose\fR]
  10. \fR[\fB\-\-log\fR \fIfile\fR]
  11. \fR[\fB\-\-mail\fR \fIcommand\fR]
  12. \fIconfig_file\fR
  13. \fR[\fIconfig_file2 ...\fR]
  14. .SH DESCRIPTION
  15. \fBlogrotate\fR is designed to ease administration of systems that generate
  16. large numbers of log files. It allows automatic rotation, compression,
  17. removal, and mailing of log files. Each log file may be handled daily,
  18. weekly, monthly, or when it grows too large.
  19. .P
  20. Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify
  21. a log more than once in one day unless the criterion for that log is
  22. based on the log's size and \fBlogrotate\fR is being run more than once
  23. each day, or unless the \fB\-f\fR or \fB\-\-force\fR option is used.
  24. .P
  25. Any number of config files may be given on the command line. Later config
  26. files may override the options given in earlier files, so the order
  27. in which the \fBlogrotate\fR config files are listed is important.
  28. Normally, a single config file which includes any other config files
  29. which are needed should be used. See below for more information on how
  30. to use the \fBinclude\fR directive to accomplish this. If a directory
  31. is given on the command line, every file in that directory is used as
  32. a config file.
  33. .P
  34. If no command line arguments are given, \fBlogrotate\fR will print
  35. version and copyright information, along with a short usage summary. If
  36. any errors occur while rotating logs, \fBlogrotate\fR will exit with
  37. non-zero status.
  38. .SH OPTIONS
  39. .TP
  40. \fB\-f\fR, \fB\-\-force\fR
  41. Tells \fBlogrotate\fR to force the rotation, even if it doesn't think
  42. this is necessary. Sometimes this is useful after adding new entries to
  43. a \fBlogrotate\fR config file, or if old log files have been removed
  44. by hand, as the new files will be created, and logging will continue
  45. correctly.
  46. .TP
  47. \fB\-d\fR, \fB\-\-debug\fR
  48. Turn on debug mode, which means that no changes are made to the logs and the
  49. \fBlogrotate\fR state file is not updated. Only debug messages are printed.
  50. .TP
  51. \fB\-s\fR, \fB\-\-state\fR \fIstatefile\fR
  52. Tells \fBlogrotate\fR to use an alternate state file. This is useful
  53. if logrotate is being run as a different user for various sets of
  54. log files. The default state file is \fI/var/lib/logrotate.status\fR.
  55. .TP
  56. \fB\-v\fR, \fB\-\-verbose\fR
  57. Turns on verbose mode, for example to display messages during rotation.
  58. .TP
  59. \fB\-l\fR, \fB\-\-log\fR \fIfile\fR
  60. Tells \fBlogrotate\fR to log verbose output into the log_file. The verbose
  61. output logged to that file is the same as when running \fBlogrotate\fR with
  62. \fB-v\fR switch. The log file is overwritten on every logrotate execution.
  63. .TP
  64. \fB\-m\fR, \fB\-\-mail\fR \fIcommand\fR
  65. Tells \fBlogrotate\fR which command to use when mailing logs. This
  66. command should accept the following arguments:
  67. .IP
  68. 1) the subject of the message given with '-s subject'
  69. .br
  70. 2) the recipient.
  71. .IP
  72. The command must then read a message on standard input
  73. and mail it to the recipient. The default mail command is
  74. \fI/bin/mail\fR.
  75. .TP
  76. \fB\-\-usage\fR
  77. Prints a short usage message.
  78. .TP
  79. \fB\-?\fR, \fB\-\-help\fR
  80. Prints help message.
  81. .TP
  82. \fB\-\-version\fR
  83. Display version information.
  84. .SH CONFIGURATION FILE
  85. \fBlogrotate\fR reads everything about the log files it should be handling
  86. from the series of configuration files specified on the command line. Each
  87. configuration file can set global options (local definitions override
  88. global ones, and later definitions override earlier ones) and specify
  89. logfiles to rotate. A simple configuration file looks like this:
  90. .nf
  91. .ta +8n
  92. # sample logrotate configuration file
  93. compress
  94. /var/log/messages {
  95. rotate 5
  96. weekly
  97. postrotate
  98. /usr/bin/killall \-HUP syslogd
  99. endscript
  100. }
  101. "/var/log/httpd/access.log" /var/log/httpd/error.log {
  102. rotate 5
  103. mail recipient@example.org
  104. size 100k
  105. sharedscripts
  106. postrotate
  107. /usr/bin/killall \-HUP httpd
  108. endscript
  109. }
  110. /var/log/news/* {
  111. monthly
  112. rotate 2
  113. olddir /var/log/news/old
  114. missingok
  115. postrotate
  116. kill \-HUP $(cat /var/run/inn.pid)
  117. endscript
  118. nocompress
  119. }
  120. ~/log/*.log {}
  121. .fi
  122. .PP
  123. The first few lines set global options; in the example, logs are
  124. compressed after they are rotated. Note that comments may appear
  125. anywhere in the config file as long as the first non-whitespace
  126. character on the line is a \fB#\fR.
  127. Values are separated from directives by whitespace and/or an optional =.
  128. Numbers must be specified in a format understood by \fBstrtoul(3)\fR.
  129. The next section of the config file defines how to handle the log file
  130. \fI/var/log/messages\fR. The log will go through five weekly rotations before
  131. being removed. After the log file has been rotated (but before the old
  132. version of the log has been compressed), the command
  133. \fI/usr/bin/killall \-HUP syslogd\fR will be executed.
  134. The next section defines the parameters for both
  135. \fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR.
  136. Each is rotated whenever it grows over 100k in size, and the old logs
  137. files are mailed (uncompressed) to recipient@\:example.org after going through 5
  138. rotations, rather than being removed. The \fBsharedscripts\fR means that
  139. the \fBpostrotate\fR script will only be run once (after the old logs have
  140. been compressed), not once for each log which is rotated.
  141. Note that log file names may be enclosed in
  142. quotes (and that quotes are required if the name contains spaces).
  143. Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\\\fR
  144. characters supported.
  145. The next section defines the parameters for all of the files in
  146. \fI/var/log/news\fR. Each file is rotated on a monthly basis. This is
  147. considered a single rotation directive and if errors occur for more than
  148. one file, the log files are not compressed.
  149. The last section uses tilde expansion to rotate log files in the home
  150. directory of the current user. This is only available, if your glob
  151. library supports tilde expansion. GNU glob does support this.
  152. Please use wildcards with caution. If you specify *, \fBlogrotate\fR will
  153. rotate all files, including previously rotated ones. A way around this
  154. is to use the \fBolddir\fR directive or a more exact wildcard (such as *.log).
  155. Here is more information on the directives which may be included in
  156. a \fBlogrotate\fR configuration file:
  157. .SH CONFIGURATION FILE DIRECTIVES
  158. These directives may be included in a \fBlogrotate\fR configuration file:
  159. .SS Rotation
  160. .TP
  161. \fBrotate \fIcount\fR
  162. Log files are rotated \fIcount\fR times before being removed or mailed to the
  163. address specified in a \fBmail\fR directive. If \fIcount\fR is 0, old versions
  164. are removed rather than rotated. If \fIcount\fR is -1, old logs are not removed
  165. at all (use with caution, may waste performance and disk space). Default is 0.
  166. .TP
  167. \fBolddir \fIdirectory\fR
  168. Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR must be
  169. on the same physical device as the log file being rotated, unless \fBcopy\fR,
  170. \fBcopytruncate\fR or \fBrenamecopy\fR option is used. The \fIdirectory\fR
  171. is assumed to be relative to the directory holding the log file
  172. unless an absolute path name is specified. When this option is used all
  173. old versions of the log end up in \fIdirectory\fR. This option may be
  174. overridden by the \fBnoolddir\fR option.
  175. .TP
  176. \fBnoolddir\fR
  177. Logs are rotated in the directory they normally reside in (this
  178. overrides the \fBolddir\fR option).
  179. .TP
  180. \fBsu \fIuser\fR \fIgroup\fR
  181. Rotate log files set under this user and group instead of using default
  182. user/group (usually root). \fIuser\fR specifies the user name used for
  183. rotation and \fIgroup\fR specifies the group used for rotation. If the
  184. user/group you specify here does not have sufficient privilege to make
  185. files with the ownership you've specified in a \fIcreate\fR instruction,
  186. it will cause an error. If logrotate runs with root privileges, it is
  187. recommended to use the \fBsu\fR directive to rotate files in directories
  188. that are directly or indirectly in control of non-privileged users.
  189. .SS Frequency
  190. .TP
  191. \fBhourly\fR
  192. Log files are rotated every hour. Note that usually \fIlogrotate\fR is
  193. configured to be run by cron daily. You have to change this configuration
  194. and run \fIlogrotate\fR hourly to be able to really rotate logs hourly.
  195. .TP
  196. \fBdaily\fR
  197. Log files are rotated every day.
  198. .TP
  199. \fBweekly\fR [\fIweekday\fR]
  200. Log files are rotated once each \fIweekday\fR, or if the date is advanced by at
  201. least 7 days since the last rotation (while ignoring the exact time). The
  202. \fIweekday\fR interpretation is following: 0 means Sunday, 1 means Monday, ...,
  203. 6 means Saturday; the special value 7 means each 7 days, irrespectively of
  204. weekday. Defaults to 0 if the \fIweekday\fR argument is omitted.
  205. .TP
  206. \fBmonthly\fR
  207. Log files are rotated the first time \fBlogrotate\fR is run in a month
  208. (this is normally on the first day of the month).
  209. .TP
  210. \fByearly\fR
  211. Log files are rotated if the current year is not the same as the last rotation.
  212. .TP
  213. \fBsize \fIsize\fR
  214. Log files are rotated only if they grow bigger than \fIsize\fR bytes. If
  215. \fIsize\fR is followed by \fIk\fR, the size is assumed to be in kilobytes.
  216. If the \fIM\fR is used, the size is in megabytes, and if \fIG\fR is used, the
  217. size is in gigabytes. So \fIsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and
  218. \fIsize 100G\fR are all valid. This option is mutually exclusive with the time
  219. interval options, and it causes log files to be rotated without regard for the
  220. last rotation time, if specified after the time criteria (the last specified
  221. option takes the precedence).
  222. .SS File selection
  223. .TP
  224. \fBmissingok\fR
  225. If the log file is missing, go on to the next one without issuing an error
  226. message. See also \fBnomissingok\fR.
  227. .TP
  228. \fBnomissingok\fR
  229. If a log file does not exist, issue an error. This is the default.
  230. .TP
  231. \fBifempty\fR
  232. Rotate the log file even if it is empty, overriding the \fBnotifempty\fR
  233. option (\fBifempty\fR is the default).
  234. .TP
  235. \fBnotifempty\fR
  236. Do not rotate the log if it is empty (this overrides the \fBifempty\fR option).
  237. .TP
  238. \fBminage\fR \fIcount\fR
  239. Do not rotate logs which are less than <count> days old.
  240. .TP
  241. \fBmaxage\fR \fIcount\fR
  242. Remove rotated logs older than <count> days. The age is only checked
  243. if the logfile is to be rotated. The files are mailed to the
  244. configured address if \fBmaillast\fR and \fBmail\fR are configured.
  245. .TP
  246. \fBminsize\fR \fIsize\fR
  247. Log files are rotated when they grow bigger than \fIsize\fR bytes, but not
  248. before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR,
  249. \fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar
  250. except that it is mutually exclusive with the time interval options, and it
  251. causes log files to be rotated without regard for the last rotation time,
  252. if specified after the time criteria (the last specified option takes the
  253. precedence). When \fBminsize\fR is used, both the size and timestamp of a
  254. log file are considered.
  255. .TP
  256. \fBmaxsize\fR \fIsize\fR
  257. Log files are rotated when they grow bigger than \fIsize\fR bytes even
  258. before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR,
  259. \fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar
  260. except that it is mutually exclusive with the time interval options, and it
  261. causes log files to be rotated without regard for the last rotation time,
  262. if specified after the time criteria (the last specified option takes the
  263. precedence). When \fBmaxsize\fR is used, both the size and timestamp of a
  264. log file are considered.
  265. .TP
  266. \fBtabooext\fR [+] \fIlist\fR
  267. The current taboo extension list is changed (see the \fBinclude\fR directive
  268. for information on the taboo extensions). If a + precedes the list of
  269. extensions, the current taboo extension list is augmented, otherwise it
  270. is replaced. At startup, the taboo extension list
  271. .IR ,v ,
  272. .IR .cfsaved ,
  273. .IR .disabled ,
  274. .IR .dpkg\-bak ,
  275. .IR .dpkg\-del ,
  276. .IR .dpkg\-dist ,
  277. .IR .dpkg\-new ,
  278. .IR .dpkg\-old ,
  279. .IR .rhn\-cfg\-tmp\-* ,
  280. .IR .rpmnew ,
  281. .IR .rpmorig ,
  282. .IR .rpmsave ,
  283. .IR .swp ,
  284. .IR .ucf\-dist ,
  285. .IR .ucf\-new ,
  286. .IR .ucf\-old ,
  287. .IR ~
  288. .TP
  289. \fBtaboopat\fR [+] \fIlist\fR
  290. The current taboo glob pattern list is changed (see the \fBinclude\fR directive
  291. for information on the taboo extensions and patterns). If a + precedes the list of
  292. patterns, the current taboo pattern list is augmented, otherwise it
  293. is replaced. At startup, the taboo pattern list is empty.
  294. .SS Files and Folders
  295. .TP
  296. \fBcreate \fImode\fR \fIowner\fR \fIgroup\fR, \fBcreate \fIowner\fR \fIgroup\fR
  297. Immediately after rotation (before the \fBpostrotate\fR script is run)
  298. the log file is created (with the same name as the log file just rotated).
  299. \fImode\fR specifies the mode for the log file in octal (the same
  300. as \fBchmod\fR(2)), \fIowner\fR specifies the user name who will own the
  301. log file, and \fIgroup\fR specifies the group the log file will belong
  302. to. Any of the log file attributes may be omitted, in which case those
  303. attributes for the new file will use the same values as the original log
  304. file for the omitted attributes. This option can be disabled using the
  305. \fBnocreate\fR option.
  306. .TP
  307. \fBnocreate\fR
  308. New log files are not created (this overrides the \fBcreate\fR option).
  309. .TP
  310. \fBcreateolddir \fImode\fR \fIowner\fR \fIgroup\fR
  311. If the directory specified by \fBolddir\fR directive does not exist, it is
  312. created. \fImode\fR specifies the mode for the \fBolddir\fR directory
  313. in octal (the same as \fBchmod\fR(2)), \fIowner\fR specifies the user name
  314. who will own the \fBolddir\fR directory, and \fIgroup\fR specifies the group
  315. the \fBolddir\fR directory will belong to. This option can be disabled using the
  316. \fBnocreateolddir\fR option.
  317. .TP
  318. \fBnocreateolddir\fR
  319. \fBolddir\fR directory is not created by logrotate when it does not exist.
  320. .TP
  321. \fBcopy\fR
  322. Make a copy of the log file, but don't change the original at all.
  323. This option can be used, for instance, to make a snapshot of the current
  324. log file, or when some other utility needs to truncate or parse the file.
  325. When this option is used, the \fBcreate\fR option will have no effect,
  326. as the old log file stays in place.
  327. .TP
  328. \fBnocopy\fR
  329. Do not copy the original log file and leave it in place.
  330. (this overrides the \fBcopy\fR option).
  331. .TP
  332. \fBcopytruncate\fR
  333. Truncate the original log file to zero size in place after creating a copy,
  334. instead of moving the old log file and optionally creating a new one.
  335. It can be used when some program cannot be told to close its logfile
  336. and thus might continue writing (appending) to the previous log file forever.
  337. Note that there is a very small time slice between copying the file and
  338. truncating it, so some logging data might be lost.
  339. When this option is used, the \fBcreate\fR option will have no effect,
  340. as the old log file stays in place.
  341. .TP
  342. \fBnocopytruncate\fR
  343. Do not truncate the original log file in place after creating a copy
  344. (this overrides the \fBcopytruncate\fR option).
  345. .TP
  346. \fBrenamecopy\fR
  347. Log file is renamed to temporary filename in the same directory by adding
  348. ".tmp" extension to it. After that, \fBpostrotate\fR script is run
  349. and log file is copied from temporary filename to final filename. This allows
  350. storing rotated log files on the different devices using \fBolddir\fR
  351. directive. In the end, temporary filename is removed.
  352. .TP
  353. \fBshred\fR
  354. Delete log files using \fBshred\fR \-u instead of unlink(). This should
  355. ensure that logs are not readable after their scheduled deletion; this is
  356. off by default. See also \fBnoshred\fR.
  357. .TP
  358. \fBnoshred\fR
  359. Do not use \fBshred\fR when deleting old log files. See also \fBshred\fR.
  360. .TP
  361. \fBshredcycles\fR \fIcount\fR
  362. Asks GNU \fBshred\fR(1) to overwrite log files \fBcount\fR times before
  363. deletion. Without this option, \fBshred\fR's default will be used.
  364. .SS Compression
  365. .TP
  366. \fBcompress\fR
  367. Old versions of log files are compressed with \fBgzip\fR(1) by default. See also
  368. \fBnocompress\fR.
  369. .TP
  370. \fBnocompress\fR
  371. Old versions of log files are not compressed. See also \fBcompress\fR.
  372. .TP
  373. \fBcompresscmd\fR
  374. Specifies which command to use to compress log files. The default is
  375. \fBgzip\fR(1). See also \fBcompress\fR.
  376. .TP
  377. \fBuncompresscmd\fR
  378. Specifies which command to use to uncompress log files. The default is
  379. \fBgunzip\fR(1).
  380. .TP
  381. \fBcompressext\fR
  382. Specifies which extension to use on compressed logfiles, if compression
  383. is enabled. The default follows that of the configured compression
  384. command.
  385. .TP
  386. \fBcompressoptions\fR
  387. Command line options may be passed to the compression program, if one is
  388. in use. The default, for \fBgzip\fR(1), is "\-6" (biased towards high
  389. compression at the expense of speed).
  390. If you use a different compression command, you may need to change the
  391. \fBcompressoptions\fR to match.
  392. .TP
  393. \fBdelaycompress\fR
  394. Postpone compression of the previous log file to the next rotation cycle.
  395. This only has effect when used in combination with \fBcompress\fR.
  396. It can be used when some program cannot be told to close its logfile
  397. and thus might continue writing to the previous log file for some time.
  398. .TP
  399. \fBnodelaycompress\fR
  400. Do not postpone compression of the previous log file to the next rotation cycle
  401. (this overrides the \fBdelaycompress\fR option).
  402. .SS Filenames
  403. .TP
  404. \fBextension \fIext\fR
  405. Log files with \fIext\fR extension can keep it after the rotation.
  406. If compression is used, the compression extension (normally \fI.gz\fR)
  407. appears after \fIext\fR. For example you have a logfile named mylog.foo
  408. and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz.
  409. .TP
  410. \fBaddextension \fIext\fR
  411. Log files are given the final extension \fIext\fR after rotation. If
  412. the original file already ends with \fIext\fR, the extension is not
  413. duplicated, but merely moved to the end, that is both \fBfilename\fR and
  414. \fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If
  415. compression is used, the compression extension (normally \fB.gz\fR)
  416. appears after \fIext\fR.
  417. .TP
  418. \fBstart \fIcount\fR
  419. This is the number to use as the base for rotation. For example, if
  420. you specify 0, the logs will be created with a .0 extension as they are
  421. rotated from the original log files. If you specify 9, log files will
  422. be created with a .9, skipping 0-8. Files will still be rotated the
  423. number of times specified with the \fBrotate\fR directive.
  424. .TP
  425. \fBdateext\fR
  426. Archive old versions of log files adding a date extension like YYYYMMDD
  427. instead of simply adding a number. The extension may be configured using
  428. the \fBdateformat\fR and \fBdateyesterday\fR options.
  429. .TP
  430. \fBnodateext\fR
  431. Do not archive old versions of log files with date extension
  432. (this overrides the \fBdateext\fR option).
  433. .TP
  434. \fBdateformat\fR \fIformat_string\fR
  435. Specify the extension for \fBdateext\fR using the notation similar to
  436. \fBstrftime\fR(3) function. Only %Y %m %d %H %M %S %V and %s specifiers are
  437. allowed.
  438. The default value is \-%Y%m%d except hourly, which uses \-%Y%m%d%H as default
  439. value. Note that also the character separating log name from the extension is
  440. part of the dateformat string. The system clock must be set past Sep 9th 2001
  441. for %s to work correctly.
  442. Note that the datestamps generated by this format must be lexically sortable
  443. (that is first the year, then the month then the day. For example 2001/12/01 is ok,
  444. but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later).
  445. This is because when using the \fBrotate\fR option, logrotate sorts all
  446. rotated filenames to find out which logfiles are older and should be removed.
  447. .TP
  448. \fBdateyesterday\fR
  449. Use yesterday's instead of today's date to create the \fBdateext\fR
  450. extension, so that the rotated log file has a date in its name that is
  451. the same as the timestamps within it.
  452. .TP
  453. \fBdatehourago\fR
  454. Use hour ago instead of current date to create the \fBdateext\fR extension,
  455. so that the rotated log file has a hour in its name that is the same as the
  456. timestamps within it. Useful with rotate \fBhourly\fR.
  457. .SS Mail
  458. .TP
  459. \fBmail \fIaddress\fR
  460. When a log is rotated out of existence, it is mailed to \fIaddress\fR. If
  461. no mail should be generated by a particular log, the \fBnomail\fR directive
  462. may be used.
  463. .TP
  464. \fBnomail\fR
  465. Do not mail old log files to any address.
  466. .TP
  467. \fBmailfirst\fR
  468. When using the \fBmail\fR command, mail the just-rotated file,
  469. instead of the about-to-expire file.
  470. .TP
  471. \fBmaillast\fR
  472. When using the \fBmail\fR command, mail the about-to-expire file,
  473. instead of the just-rotated file (this is the default).
  474. .SS Scripts
  475. .TP
  476. \fBinclude \fIfile_or_directory\fR
  477. Reads the file given as an argument as if it was included inline
  478. where the \fBinclude\fR directive appears. If a directory is given,
  479. most of the files in that directory are read in alphabetic order
  480. before processing of the including file continues. The only files
  481. which are ignored are files which are not regular files (such as
  482. directories and named pipes) and files whose names end with one of
  483. the taboo extensions or patterns, as specified by the \fBtabooext\fR
  484. or \fBtaboopat\fR directives, respectively.
  485. .TP
  486. \fBsharedscripts\fR
  487. Normally, \fBprerotate\fR and \fBpostrotate\fR scripts are run for each
  488. log which is rotated and the absolute path to the log file is passed as first
  489. argument to the script. That means a single script may be run multiple
  490. times for log file entries which match multiple files (such as the
  491. \fI/var/log/news/*\fR example). If \fBsharedscripts\fR is specified, the scripts
  492. are only run once, no matter how many logs match the wildcarded pattern,
  493. and whole pattern is passed to them.
  494. However, if none of the logs in the pattern require rotating, the scripts
  495. will not be run at all. If the scripts exit with error, the remaining
  496. actions will not be executed for any logs. This option overrides the
  497. \fBnosharedscripts\fR option and implies \fBcreate\fR option.
  498. .TP
  499. \fBnosharedscripts\fR
  500. Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log file which
  501. is rotated (this is the default, and overrides the \fBsharedscripts\fR
  502. option). The absolute path to the log file is passed as first argument
  503. to the script. The absolute path to the final rotated log file is passed as
  504. the second argument to the \fBpostrotate\fR script. If the scripts exit with
  505. error, the remaining actions will not be executed for the affected log only.
  506. .TP
  507. \fBfirstaction\fR/\fBendscript\fR
  508. The lines between \fBfirstaction\fR and \fBendscript\fR (both of which
  509. must appear on lines by themselves) are executed (using \fB/bin/sh\fR) once
  510. before all log files that match the wildcarded pattern are rotated, before
  511. prerotate script is run and only if at least one log will actually be rotated.
  512. These directives may only appear inside a log file definition. Whole pattern is
  513. passed to the script as first argument. If the script exits with error,
  514. no further processing is done. See also \fBlastaction\fR.
  515. .TP
  516. \fBlastaction\fR/\fBendscript\fR
  517. The lines between \fBlastaction\fR and \fBendscript\fR (both of which
  518. must appear on lines by themselves) are executed (using \fB/bin/sh\fR) once
  519. after all log files that match the wildcarded pattern are rotated, after
  520. postrotate script is run and only if at least one log is rotated. These
  521. directives may only appear inside a log file definition. Whole pattern is
  522. passed to the script as first argument. If the script exits
  523. with error, just an error message is shown (as this is the last
  524. action). See also \fBfirstaction\fR.
  525. .TP
  526. \fBprerotate\fR/\fBendscript\fR
  527. The lines between \fBprerotate\fR and \fBendscript\fR (both of which
  528. must appear on lines by themselves) are executed (using \fB/bin/sh\fR) before
  529. the log file is rotated and only if the log will actually be rotated. These
  530. directives may only appear inside a log file definition. Normally,
  531. the absolute path to the log file is passed as first argument to the script.
  532. If \fBsharedscripts\fR is specified, whole pattern is passed to the script.
  533. See also \fBpostrotate\fR.
  534. See \fBsharedscripts\fR and \fBnosharedscripts\fR for error handling.
  535. .TP
  536. \fBpostrotate\fR/\fBendscript\fR
  537. The lines between \fBpostrotate\fR and \fBendscript\fR (both of which
  538. must appear on lines by themselves) are executed (using \fB/bin/sh\fR)
  539. after the log file is rotated. These directives may only appear inside
  540. a log file definition. Normally, the absolute path to the log file is
  541. passed as first argument to the script and the absolute path to the final
  542. rotated log file is passed as the second argument to the script. If
  543. \fBsharedscripts\fR is specified, the whole pattern is passed as the first
  544. argument to the script, and the second argument is omitted.
  545. See also \fBprerotate\fR. See \fBsharedscripts\fR and \fBnosharedscripts\fR
  546. for error handling.
  547. .TP
  548. \fBpreremove\fR/\fBendscript\fR
  549. The lines between \fBpreremove\fR and \fBendscript\fR (both of which must
  550. appear on lines by themselves) are executed (using \fB/bin/sh\fR) once just
  551. before removal of a log file. The logrotate will pass
  552. the name of file which is soon to be removed. See also \fBfirstaction\fR.
  553. .SH FILES
  554. .TS
  555. tab(:);
  556. left l l.
  557. \fI/var/lib/logrotate.status\fR:Default state file.
  558. \fI/etc/logrotate.conf\fR:Configuration options.
  559. .TE
  560. .SH "SEE ALSO"
  561. .BR chmod (2),
  562. .BR gunzip (1),
  563. .BR gzip (1),
  564. .BR mail (1),
  565. .BR shred (1),
  566. .BR strftime (3),
  567. .BR strtoul (3),
  568. <https://github.com/logrotate/logrotate>
  569. .SH AUTHORS
  570. .nf
  571. Erik Troan, Preston Brown, Jan Kaluza.
  572. <https://github.com/logrotate/logrotate>
  573. .fi