Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 074c356

Browse files
authoredFeb 7, 2025
auditd.cron.5: Describe time-based log rotation setup (#434)
* auditd.cron.5: Describe time-based log rotation setup * Use the latest human readable auditctl signal names
1 parent 1f31d79 commit 074c356

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed
 

‎audit.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ fi
210210
%attr(644,root,root) %{_mandir}/man8/aulastlog.8.gz
211211
%attr(644,root,root) %{_mandir}/man8/ausyscall.8.gz
212212
%attr(644,root,root) %{_mandir}/man5/auditd.conf.5.gz
213+
%attr(644,root,root) %{_mandir}/man5/auditd.cron.5.gz
213214
%attr(644,root,root) %{_mandir}/man5/auditd-plugins.5.gz
214215
%attr(755,root,root) %{_sbindir}/auditd
215216
%attr(755,root,root) %{_sbindir}/ausearch

‎docs/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ ausearch_next_event.3 ausearch_cur_event.3 ausearch_set_stop.3 \
6868
get_auditfail_action.3 set_aumessage_mode.3 \
6969
audispd-zos-remote.8 libaudit.conf.5 \
7070
augenrules.8 audit_set_backlog_wait_time.3 \
71-
zos-remote.conf.5
71+
zos-remote.conf.5 \
72+
auditd.cron.5
7273

‎docs/auditd.conf.5

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ record type >= AUDIT_MAC_UNLBL_ALLOW && record type <= AUDIT_MAC_CALIPSO_DEL (th
432432
for the stream being processed, the time of the event is over end_of_event_timeout seconds old.
433433
.RE
434434

435+
.SH LOG ROTATION POLICY
436+
437+
By default, auditd uses size-based log rotation. If you prefer time-based rotation (e.g., hourly, daily, weekly, or custom schedule), refer to auditd.cron(5) for configuration details.
438+
435439
.SH FILES
436440
.TP
437441
.I /etc/audit/auditd.conf
@@ -440,7 +444,8 @@ Audit daemon configuration file
440444
.SH "SEE ALSO"
441445
.BR auditd (8),
442446
.BR audisp\-remote.conf (5),
443-
.BR auditd\-plugins (5).
447+
.BR auditd\-plugins (5),
448+
.BR auditd.cron (5).
444449

445450
.SH AUTHOR
446451
Steve Grubb

‎docs/auditd.cron.5

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.TH AUDITD.CRON "5" "Feb 2025" "Red Hat" "System Administration Utilities"
2+
.SH NAME
3+
auditd.conf \- time-based rotation of audit logs
4+
.SH DESCRIPTION
5+
By default, the audit daemon (auditd) supports size-based log rotation, where logs are rotated once they reach a specified size, as configured in
6+
.I /etc/audit/auditd.conf.
7+
This manual describes an alternative method: time-based log rotation using
8+
.B cron.
9+
Using this approach, audit logs can be rotated at specified intervals (hourly, daily, weekly or on a custom date), regardless of their size.
10+
11+
.SH CONFIGURATION
12+
13+
.B 1.Disable Size-Based Rotation:
14+
15+
To enable time-based log rotation, first disable \fBauditd's\fP built-in size-based rotation by setting the following parameter in
16+
.I /etc/audit/auditd.conf:
17+
18+
.RS
19+
max_log_file_action = ignore
20+
.RE
21+
22+
.B 2. Configure Log Retention:
23+
24+
The
25+
.B num_logs
26+
parameter determines the number of rotated log files to keep. For daily rotation, setting
27+
28+
.RS
29+
num_logs = 7
30+
.RE
31+
32+
ensures that logs from the last seven days are retained. However, on busy systems, audit logs may grow rapidly, potentially leading to a lack of disk space. To prevent this, ensure that the
33+
.B space_left_action
34+
parameter is configured to handle low-disk-space situations appropriately.
35+
36+
.B 3. Apply Configuration Changes:
37+
38+
After modifying the main auditd configuration file, reload auditd to apply the changes:
39+
40+
.RS
41+
auditctl --signal reload
42+
.RE
43+
44+
.B 4. Deploy the Rotation Script:
45+
46+
Copy the provided
47+
.B auditd.cron
48+
script to the appropriate cron directory (
49+
.IR cron.daily
50+
or
51+
.IR cron.hourly
52+
or
53+
.IR cron.weekly
54+
, depending on your rotation preference). Then, ensure the file has the correct SELinux labels:
55+
56+
.RS
57+
cp /usr/share/doc/audit/auditd.cron /etc/cron.daily
58+
.RE
59+
60+
.SH "SEE ALSO"
61+
.BR auditd.conf (5),
62+
.BR auditd (8),
63+
.BR cron(8).
64+
65+
.SH AUTHOR
66+
Attila Lakatos

‎init.d/auditd.cron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# based on time instead of log size.
66
##########
77

8-
/sbin/auditctl --signal usr1
8+
/sbin/auditctl --signal rotate
99
EXITVALUE=$?
1010
if [ $EXITVALUE != 0 ]; then
1111
/usr/bin/logger -t auditd "ALERT auditctl exited abnormally with [$EXITVALUE] while rotating the logs"

0 commit comments

Comments
 (0)
Please sign in to comment.