1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
|
'\" te
.\" Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH LOGADM 1M "June 20, 2021"
.SH NAME
logadm \- manage endlessly growing log files
.SH SYNOPSIS
.nf
\fBlogadm\fR
.fi
.LP
.nf
\fBlogadm\fR [\fB-\fIoptions\fR\fR] \fIlogname\fR...
.fi
.SH DESCRIPTION
\fBlogadm\fR is a general log rotation tool that is suitable for running from
\fBcron\fR(1M).
.sp
.LP
Without arguments, \fBlogadm\fR reads the \fB/etc/logadm.conf\fR file, and for
every entry found in that file checks the corresponding log file to see if it
should be rotated. Typically this check is done each morning by an entry in the
root's \fBcrontab\fR.
.sp
.LP
If the \fIlogname\fR argument is specified, \fBlogadm\fR renames the
corresponding log file by adding a suffix so that the most recent log file ends
with \fB\&.0\fR (that is, \fIlogfile\fR\fB\&.0\fR), the next most recent ends
with \fB\&.1\fR (that is, \fIlogfile\fR\fB\&.1\fR), and so forth. By default,
ten versions of old log files are kept (that is, \fIlogfile\fR\fB\&.0\fR
through \fIlogfile\fR\fB\&.9\fR). At the point when what would be the eleventh
file is logged, \fBlogadm\fR automatically deletes the oldest version to keep
the count of files at ten.
.sp
.LP
\fBlogadm\fR takes a number of \fIoptions\fR. You can specify these options on
the command line or in the \fB/etc/logadm.conf\fR file. The \fBlogadm\fR
command searches \fB/etc/logadm.conf\fR for lines of the form \fIlogname\fR
\fIoptions\fR
.sp
.ne 2
.na
\fB\fIlogname\fR\fR
.ad
.sp .6
.RS 4n
Identifies an entry in \fB/etc/logadm.conf\fR. This can be a name or the
pathname of the log file. If you specify a log file, rather than a name, for
this field, it must be a fully qualified pathname.
.RE
.sp
.ne 2
.na
\fB\fIoptions\fR\fR
.ad
.sp .6
.RS 4n
Identifies command line options exactly as they would be entered on the command
line. This allows commonly used log rotation policies to be stored in the
\fB/etc/logadm.conf\fR file. See \fBEXAMPLES\fR.
.sp
If \fIoptions\fR are specified both in \fB/etc/logadm.conf\fR and on the
command line, those in the \fB/etc/logadm.conf\fR file are applied first.
Therefore, the command line options override those in \fB/etc/logadm.conf\fR.
.sp
Log file names specified in \fB/etc/logadm.conf\fR may contain filename
substitution characters such as \fB*\fR and \fB?\fR, that are supported by
\fBcsh\fR(1).
.RE
.sp
.LP
Two options control when a log file is rotated. They are: \fB-s\fR size
\fB-p\fR period.
.sp
.LP
When using more than one of these options at a time, there is an implied
\fBand\fR between them. This means that all conditions must be met before the
log is rotated.
.sp
.LP
If neither of these two options are specified, the default conditions for
rotating a log file are: \fB\fR\fB-s\fR \fB1b\fR \fB-p\fR \fB1w\fR, which means
the log file is only rotated if the size is non-zero and if at least 1 week has
passed since the last time it was rotated.
.sp
.LP
By specifying \fB\fR\fB-p\fR \fBnever\fR as a rotation condition, any other
rotation conditions are ignored and \fBlogadm\fR moves on to the expiration of
old log files. By specifying \fB\fR\fB-p\fR \fBnow\fR as a rotation condition,
a log rotation is forced.
.sp
.LP
Unless specified by the \fB-o\fR, \fB-g\fR, or \fB-m\fR options, \fBlogadm\fR
replaces the log file (after renaming it) by creating an empty file whose
owner, group ID, and permissions match the original file.
.sp
.LP
Three options control when old log files are expired: \fB-A\fR age \fB-C\fR
count \fB-S\fR size. These options expire the oldest log files until a
particular condition or conditions are met. For example, the combination of the
\fB\fR\fB-C\fR \fB5\fR and \fB\fR\fB-S\fR \fB10m\fR options expires old log
files until there are no more than 5 of them \fBand\fR their combined disk usage
is no more than 10 megabytes. If none of these options are specified, the
default expiration is \fB\fR\fB-C\fR \fB10\fR which keeps ten old log files. If
no files are to be expired, use \fB\fR\fB-C\fR \fB0\fR to prevent expiration by
default.
.SH OPTIONS
The following options are supported:
.sp
.ne 2
.na
\fB\fB-a\fR \fIpost_command\fR\fR
.ad
.sp .6
.RS 4n
Execute the \fIpost_command\fR after renaming the log file. \fIpost_command\fR
is passed to \fBsh\fR \fB-c\fR.
.sp
Specify \fIpost_command\fR as a valid shell command. Use quotes to protect
spaces or shell metacharacters in \fIpost_command\fR.
.sp
This option can be used to restart a daemon that is writing to the file. When
rotating multiple logs with one \fBlogadm\fR command, \fIpost_command\fR is
executed only once after all the logs are rotated, not once per rotated log.
.RE
.sp
.ne 2
.na
\fB\fB-A\fR \fIage\fR\fR
.ad
.sp .6
.RS 4n
Delete any versions that have not been modified for the amount of time
specified by \fIage\fR.
.sp
Specify \fIage\fR as a number followed by an \fBh\fR (hours), \fBd\fR (days),
\fBw\fR(weeks), \fBm\fR (months), or \fBy\fR (years).
.RE
.sp
.ne 2
.na
\fB\fB-b\fR \fIpre_command\fR\fR
.ad
.sp .6
.RS 4n
Execute \fIpre_command\fR before renaming the log file. \fIpre_command\fR is
passed to \fBsh\fR \fB-c\fR.
.sp
Specify \fIpre_command\fR as a valid shell command. Use quotes to protect
spaces or shell metacharacters in the \fIpre_command\fR.
.sp
This option can be used to stop a daemon that is writing to the file. When
rotating multiple logs with one \fBlogadm\fR command, \fIpre_command\fR is
executed only once before all the logs are rotated, not once per rotated log.
.RE
.sp
.ne 2
.na
\fB\fB-c\fR\fR
.ad
.sp .6
.RS 4n
Rotate the log file by copying it and truncating the original logfile to zero
length, rather than renaming the file.
.RE
.sp
.ne 2
.na
\fB\fB-C\fR \fIcount\fR\fR
.ad
.sp .6
.RS 4n
Delete the oldest versions until there are not more than \fIcount\fR files
left.
.sp
If no expire options (\fB-A\fR, \fB-C\fR, or \fB-S\fR) are specified,
\fB\fR\fB-C\fR \fB10\fR is the default. To prevent the default expire rule from
being added automatically, specify \fB\fR\fB-C\fR \fB0\fR .
.RE
.sp
.ne 2
.na
\fB\fB-e\fR \fImail_addr\fR\fR
.ad
.sp .6
.RS 4n
Send error messages by email to \fImail_addr\fR.
.sp
As \fBlogadm\fR is typically run from \fBcron\fR(1M), error messages are
captured by \fBcron\fR and mailed to the owner of the \fBcrontab\fR.
.sp
This option is useful if you want the mail regarding error messages to go to
another address instead. If no errors are encountered, no mail message is
generated.
.RE
.sp
.ne 2
.na
\fB\fB-E\fR \fIcmd\fR\fR
.ad
.sp .6
.RS 4n
Execute \fIcmd\fR to expire the file, rather than deleting the old log file to
expire it.
.sp
\fIcmd\fR is passed it to \fBsh\fR \fB-c\fR. The file is considered expired
after \fIcmd\fR completes. If the old log file is not removed or renamed by the
\fIcmd\fR, \fBlogadm\fR considers it for expiration the next time that it runs
on the specified log file. If present, the keyword \fB$file\fR is expanded in
the specified \fIcmd\fR to the name of the file being expired.
.sp
This option is useful for tasks such as mailing old log files to
administrators, or copying old log files to long term storage.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR \fIconf_file\fR\fR
.ad
.sp .6
.RS 4n
Use \fIconf_file\fR instead of \fB/etc/logadm.conf\fR.
.sp
This option allows non-root users to keep their own \fBlogadm\fR configuration
files.
.RE
.sp
.ne 2
.na
\fB\fB-g\fR \fIgroup\fR\fR
.ad
.sp .6
.RS 4n
Create a new empty file with the \fBID\fR specified by \fIgroup\fR, instead of
preserving the group \fBID\fR of the log file.
.sp
Specify \fIgroup\fR by name or by numeric group \fBID\fR, as accepted by
\fBchgrp\fR(1).
.sp
This option requires the ability to change file group ownership using the
\fBchgrp\fR(1) command.
.RE
.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.sp .6
.RS 4n
Print a help message that describes \fBlogadm\fR's options.
.RE
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.sp .6
.RS 4n
Use local time rather than the Coordinated Universal Time (UTC) when naming
rotated log files (see the discussion of percent sequences in the templates
supplied with the \fB-t\fR option).
.RE
.sp
.ne 2
.na
\fB\fB-m\fR \fImode\fR\fR
.ad
.sp .6
.RS 4n
Create a new empty file with the mode specified by \fImode\fR, instead of
preserving the mode of the log file.
.sp
Specify \fImode\fR in any form that is accepted by the \fBchmod\fR(1) command.
.RE
.sp
.ne 2
.na
\fB\fB-M\fR \fIcmd\fR\fR
.ad
.sp .6
.RS 4n
Use \fIcmd\fR to rename the log file. If the keyword \fB$file\fR is specified,
it is expanded to the name of the log file. Similarly, the keyword \fB$nfile\fR
is expanded to the new name of the log file. The \fB$nfile\fR keyword is only
available with commands provided with the \fB-M\fR option. After the command
completes, the log file is replaced by the rotate file. The default \fIcmd\fR
is "\fB/bin/mv\fR \fB$file\fR\fB\fR\fB$nfile\fR".
.RE
.sp
.ne 2
.na
\fB\fB-n\fR \fI\fR\fR
.ad
.sp .6
.RS 4n
Print the actions that the \fBlogadm\fR command will perform without actually
performing them.
.sp
This option is useful for checking arguments before making any changes to the
system.
.sp
It is important to remember, however, that since log rotating actions are only
printed with this option, \fBlogadm\fR might not find files that need expiring,
but if run without the \fB-n\fR \fBlogadm\fR might create a file that needs
expiring by performing the log rotating actions. Therefore, if you see no files
being expired with the \fB-n\fR option, files still might be expired without
it.
.RE
.sp
.ne 2
.na
\fB\fB-N\fR\fR
.ad
.sp .6
.RS 4n
Prevent an error message if the specified logfile does not exist. Normally,
\fBlogadm\fR produces an error message if the log file is not found. With
\fB-N\fR, if the log file doesn't exist \fBlogadm\fR moves on to the expire
rules (if any) and then to the next log file (if any), without creating the
empty replacement log file.
.RE
.sp
.ne 2
.na
\fB\fB-o\fR \fIowner\fR\fR
.ad
.sp .6
.RS 4n
Create the new empty file with \fIowner\fR, instead of preserving the owner of
the log file.
.sp
Specify \fIowner\fR in any form that is accepted by the \fBchown\fR(1) command.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR \fIperiod\fR\fR
.ad
.sp .6
.RS 4n
Rotate a log file after the specified time period (\fIperiod\fR).
.sp
Specify \fIperiod\fR as a number followed by \fBd\fR for days, \fBh\fR for
hours, \fBw\fR for weeks, \fBm\fR for months (30 days) or \fBy\fR for years.
There are also two special values for period: \fBnow\fR and \fBnever\fR.
"\fB\fR\fB-p\fR \fBnow\fR" forces log rotation. "\fB\fR\fB-p\fR \fBnever\fR"
forces no log rotation.
.RE
.sp
.ne 2
.na
\fB\fB-P\fR \fItimestamp\fR\fR
.ad
.sp .6
.RS 4n
Used by \fBlogadm\fR to record the last time the log was rotated in
\fB/etc/logadm.conf\fR.
.sp
This option uses \fItimestamp\fR to determine if the log rotation period has
passed. The format of \fItimestamp\fR matches the format generated by
\fBctime\fR(3C), with quotes around it to protect embedded spaces.
\fItimestamp\fR is always recorded in the Coordinated Universal Time (UTC)
timezone.
.RE
.sp
.ne 2
.na
\fB\fB-r\fR\fR
.ad
.sp .6
.RS 4n
Remove any entries corresponding to the specified \fIlogname\fR from the
\fB/etc/logadm.conf\fR.
.RE
.sp
.ne 2
.na
\fB\fB-R\fR \fIcmd\fR\fR
.ad
.sp .6
.RS 4n
Run the \fIcmd\fR when an old log file is created by a log rotation. If the
keyword \fB$file\fR is embedded in the specified command, it is expanded to the
name of the old log file just created by log rotation.
.sp
This option is useful for processing log file contents after rotating the log.
\fIcmd\fR is executed by passing it to \fBsh\fR \fB-c\fR. When rotating
multiple logs with one logadm command, the command supplied with \fB-R\fR is
executed once every time a log is rotated. This is useful for post-processing a
log file (that is, sorting it, removing uninteresting lines, etc.). The
\fB-a\fR option is a better choice for restarting daemons after log rotation.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR \fIsize\fR\fR
.ad
.sp .6
.RS 4n
Rotate the log file only if its size is greater than or equal to \fIsize\fR.
.sp
Specify \fIsize\fR as a number followed by the letter \fBb\fR for bytes,
\fBk\fR for kilobytes, \fBm\fR for megabytes, or \fBg\fR for gigabytes.
.RE
.sp
.ne 2
.na
\fB\fB-S\fR \fIsize\fR\fR
.ad
.sp .6
.RS 4n
Delete the oldest versions until the total disk space used by the old log files
is less than the specified size.
.sp
Specify \fIsize\fR as a number followed by the letter \fBb\fR for bytes,
\fBk\fR for kilobytes, \fBm\fR for megabytes, or \fBg\fR for gigabytes.
.RE
.sp
.ne 2
.na
\fB\fB-t\fR \fItemplate\fR\fR
.ad
.sp .6
.RS 4n
Specify the template to use when renaming log files.
.sp
\fItemplate\fR can be a simple name, such as \fB/var/adm/oldfile\fR, or it can
contain special keywords which are expanded by \fBlogadm\fR and are in the form
\fB$\fR\fIword\fR. Allowed sequences are:
.sp
.ne 2
.na
\fB$\fIbasename\fR\fR
.ad
.sp .6
.RS 4n
The log file name, without the directory name
.RE
.sp
.ne 2
.na
\fB$\fIdirname\fR\fR
.ad
.sp .6
.RS 4n
The directory of the file to be rotated
.RE
.sp
.ne 2
.na
\fB$\fIdomain\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBdomainname\fR
.RE
.sp
.ne 2
.na
\fB$\fIfile\fR\fR
.ad
.sp .6
.RS 4n
The full path name of the file to be rotated
.RE
.sp
.ne 2
.na
\fB$\fIisa\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBuname\fR \fB-p\fR
.RE
.sp
.ne 2
.na
\fB$\fImachine\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBuname\fR \fB-m\fR
.RE
.sp
.ne 2
.na
\fB$\fIn\fR\fR
.ad
.sp .6
.RS 4n
The version number, \fB0\fR is most recent, \fB1\fR is next most recent, and so
forth
.RE
.sp
.ne 2
.na
\fB$\fIN\fR\fR
.ad
.sp .6
.RS 4n
The same as $\fIn\fR, but starts at \fB1\fR instead of zero
.RE
.sp
.ne 2
.na
\fB$\fInodename\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBuname\fR \fB-n\fR
.RE
.sp
.ne 2
.na
\fB$\fIplatform\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBuname\fR \fB-i\fR
.RE
.sp
.ne 2
.na
\fB$\fIrelease\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBuname\fR \fB-r\fR
.RE
.sp
.ne 2
.na
\fB$\fIsecs\fR\fR
.ad
.sp .6
.RS 4n
The number of seconds since \fB00:00:00 UTC, January 1,1970\fR
.RE
.sp
.ne 2
.na
\fB$\fIzonename\fR\fR
.ad
.sp .6
.RS 4n
Expands to the output of \fBzonename\fR(1).
.RE
To actually have the dollar sign character in the file name, use \fB$$\fR. Any
percent sequences allowed by \fBstrftime\fR(3C) are also allowed, for example,
\fB%d\fR expands to the day of the month. To actually have a percent sign
character in the file name, use \fB%%\fR. Both dollar-sign keywords and percent
sequences can appear anywhere in the template. If the template results in a
pathname with non-existent directories, they are created as necessary when
rotating the log file.
.sp
If no \fB-t\fR option is specified, the default template is \fB$file.$n\fR.
Actual \fBrotation\fR of log files, where each version is shifted up until it
expires is done using the \fB$n\fR keyword. If the template does not contain
the \fB$n\fR keyword, the log file is simply renamed to the new name and then
the expire rules, if any, are applied.
.RE
.sp
.ne 2
.na
\fB\fB-T\fR \fIpattern\fR\fR
.ad
.sp .6
.RS 4n
Normally \fBlogadm\fR looks for a list of old log files by turning the template
(specified with the \fB-t\fR option) into a pattern and finding existing files
whose names match that pattern. The \fB-T\fR option causes the given pattern to
be used instead.
.sp
This option is useful if another program fiddles with the old log file names,
like a \fBcron\fR job to compress them over time. The pattern is in the form of
a pathname with special characters such as \fB*\fR and \fB?\fR as supported by
\fBcsh\fR(1) filename substitution.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.sp .6
.RS 4n
Print information about the actions being executed in verbose mode.
.RE
.sp
.ne 2
.na
\fB\fB-V\fR\fR
.ad
.sp .6
.RS 4n
Validate the configuration file.
.sp
This option validates that an entry for the specified \fIlogname\fR exists in
the \fB/etc/logadm.conf\fR file and is syntactically correct. If \fIlogname\fR
is not specified, all entries in the configuration file are validated. If a
\fBlogname\fR argument is specified, the command validates the syntax of that
entry. If the entry is found, it is printed and the exit value of the command
is true. Otherwise the exit value is false.
.RE
.sp
.ne 2
.na
\fB\fB-w\fR \fIentryname\fR\fR
.ad
.sp .6
.RS 4n
Write an entry into the config file (that is, \fB/etc/logadm.conf\fR) that
corresponds to the current command line arguments. If an entry already existed
for the specified \fIentryname\fR, it is removed first. This is the preferred
method for updating \fB/etc/logadm.conf\fR, because it prevents syntax errors.
The \fIentryname\fR is an argument to an invocation of \fBlogadm\fR.
\fIentryname\fR might be chosen as something easy to remember or it can be the
pathname of the log file. If a pathname, rather than a name is used, it must be
a fully qualified pathname.
.sp
If no log file name is provided on a \fBlogadm\fR command line, the entry name
is assumed to be the same as the log file name. For example, the following two
lines achieve the same thing, keeping two copies of rotated log files:
.sp
.in +2
.nf
% logadm -C2 -w mylog /my/really/long/log/file/name
% logadm -C2 -w /my/really/long/log/file/name
.fi
.in -2
.sp
.RE
.sp
.ne 2
.na
\fB\fB-z\fR \fIcount\fR\fR
.ad
.sp .6
.RS 4n
Compress old log files after all other commands have been executed. \fIcount\fR
of the most recent log files are left uncompressed, therefore making the
\fIcount\fR most recent files easier to peruse. Use \fIcount\fR of zero to
compress all old logs.
.sp
The compression is done with \fBgzip\fR(1) and the resulting log file has the
suffix of \fB\&.gz\fR.
.RE
.SH OPERANDS
The following operands are supported:
.sp
.ne 2
.na
\fB\fIlogname\fR\fR
.ad
.sp .6
.RS 4n
Identifies the name of the entry in \fB/etc/logadm.conf\fR. If the log file
name is specified in the \fIlogname\fR field, it is assumed that \fIlogname\fR
is the same as the actual log file name.
.RE
.SH EXAMPLES
\fBExample 1 \fRRotating a File and Keeping Previous Versions
.sp
.LP
The following example rotates the \fB/var/adm/exacct/proc\fR file, keeping ten
previous versions in \fB/var/adm/exacct/proc.0\fR through
\fB/var/adm/exacct/proc.9\fR.
.sp
.LP
Tell \fBlogadm\fR to copy the file and truncate it.
.sp
.in +2
.nf
% logadm -c /var/adm/exacct/proc
.fi
.in -2
.sp
.LP
\fBExample 2 \fRRotating syslog
.sp
.LP
The following example rotates \fBsyslog\fR and keeps eight log files. Old log
files are put in the directory \fB/var/oldlogs\fR instead of \fB/var/log\fR:
.sp
.in +2
.nf
% logadm -C8 -t'/var/oldlogs/syslog.$n' /var/log/syslog
.fi
.in -2
.sp
.LP
\fBExample 3 \fRRotating /var/adm/sulog and Expiring Based on Age
.sp
.LP
The following entry in the \fB/etc/logadm.conf\fR file rotates the
\fB/var/adm/sulog\fR file and expires any copies older than 30 days.
.sp
.in +2
.nf
/var/adm/sulog -A 30d
.fi
.in -2
.sp
.LP
\fBExample 4 \fRRotating Files and Expiring Based on Disk Usage
.sp
.LP
The following entry in the \fB/etc/logadm.conf\fR file rotates the
\fB/var/adm/sulog\fR file and expires old log files when more than 100
megabytes are used by the sum of all the rotated log files.
.sp
.in +2
.nf
/var/adm/sulog -S 100m
.fi
.in -2
.sp
.LP
\fBExample 5 \fRCreating an Entry that Stores the Logfile Name
.sp
.LP
This example creates an entry storing the log file name and the fact that we
want to keep 20 copies in \fB/etc/logadm.conf\fR, but the \fB\fR\fB-p\fR
\fBnever\fR means the entry is ignored by the normal \fBlogadm\fR run from
root's crontab every morning.
.sp
.in +2
.nf
% logadm -w locallog /usr/local/logfile -C20 -p never
.fi
.in -2
.sp
.sp
.LP
Use the following entry on the command line to override the \fB\fR\fB-p\fR
\fBnever\fR option:
.sp
.in +2
.nf
% logadm -p now locallog
.fi
.in -2
.sp
.LP
\fBExample 6 \fRRotating the apache Error and Access Logs
.sp
.LP
The following example rotates the apache error and access logs monthly to
filenames based on current year and month. It keeps the 24 most recent copies
and tells apache to restart after renaming the logs.
.sp
.LP
This command is run once, and since the \fB-w\fR option is specified, an entry
is made in \fB/etc/logadm.conf\fR so the apache logs are rotated from now on.
.sp
.in +2
.nf
% logadm -w apache -p 1m -C 24\e
-t '/var/apache/old-logs/$basename.%Y-%m'\e
-a '/usr/apache/bin/apachectl graceful'\e
'/var/apache/logs/*{access,error}_log'
.fi
.in -2
.sp
.sp
.LP
This example also illustrates that the entry name supplied with the \fB-w\fR
option doesn't have to match the log file name. In this example, the entry name
is \fBapache\fR and once the line has been run, the entry in
\fB/etc/logadm.conf\fR can be forced to run by executing the following command:
.sp
.in +2
.nf
% logadm -p now apache
.fi
.in -2
.sp
.sp
.LP
Because the expression matching the apache log file names was enclosed in
quotes, the expression is stored in \fB/etc/logadm.conf\fR, rather than the
list of files that it expands to. This means that each time \fBlogadm\fR runs
from \fBcron\fR it expands that expression and checks all the log files in the
resulting list to see if they need rotating.
.sp
.LP
The following command is an example without the quotes around the log name
expression. The shell expands the last argument into a list of log files that
exist at the time the command is entered, and writes an entry to
\fB/etc/logadm.conf\fR that rotates the files.
.sp
.in +2
.nf
logadm -w apache /var/apache/logs/*_log
.fi
.in -2
.sp
.SH FILES
.ne 2
.na
\fB\fB/etc/logadm.conf\fR\fR
.ad
.sp .6
.RS 4n
configuration file for \fBlogadm\fR command
.RE
.SH ATTRIBUTES
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Evolving
.TE
.SH SEE ALSO
\fBchgrp\fR(1), \fBchmod\fR(1), \fBchown\fR(1), \fBcsh\fR(1), \fBgzip\fR(1),
\fBcron\fR(1M), \fBctime\fR(3C), \fBstrftime\fR(3C), \fBlogadm.conf\fR(4),
\fBattributes\fR(5)
.SH NOTES
When \fBlogadm\fR applies expire conditions (supplied by the \fB-A\fR,
\fB-C\fR, and \fB-S\fR options), it deletes files, the oldest first, until the
conditions are satisfied. If the template used for naming the old logs
contained \fB$n\fR or \fB$N\fR, \fBlogadm\fR picks the highest value of
\fB$n\fR or \fB$N\fR found in the old log file names first. If the template
used is something else, \fBlogadm\fR uses the modification time to determine
which files to expire first. This may not be the expected behavior if an old
log file has been modified since it was rotated.
.sp
.LP
Depending on log file sizes and number of log files, log file rotations can be
very time-consuming.
.sp
.LP
By default, \fBlogadm\fR works in \fBGMT\fR. Therefore, all entries written to
the \fB/etc/logadm.conf\fR file (see \fBlogadm.conf\fR(4)) will have a
\fBGMT\fR timestamp. Users can use the \fB-l\fR option to set \fBlogadm\fR to
local time.
|