Skip to content

Commit e729ef5

Browse files
committed
add auto SSM clean timer service
1 parent 8684d65 commit e729ef5

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/splunkconf-cloud-recovery.sh

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ exec >> /var/log/splunkconf-cloud-recovery-debug.log 2>&1
267267
# 20241115 up to 9.3.2
268268
# 20250406 up to 9.4.1
269269
# 20250505 up to 9.4.2
270+
# 20250606 add auto SSM clean timer service
270271

271-
VERSION="20250505a"
272+
VERSION="20250506a"
272273

273274
# dont break script on error as we rely on tests for this
274275
set +e
@@ -2755,6 +2756,47 @@ else
27552756
fi
27562757

27572758

2759+
echo "***************************** CLEAN UP SSM timers *********************
2760+
# AWS SSM files may accumulate leading to a disk full situation and as such preventing Splunk to run
2761+
2762+
cat <<EOF >/etc/systemd/system/cleanssm.service
2763+
2764+
#
2765+
# Clean AWS SSM directory to free up space added by SSM jobs
2766+
2767+
[Unit]
2768+
Description=Purge old AWS SSM files
2769+
After=sysstat.service
2770+
2771+
[Service]
2772+
Type=oneshot
2773+
User=root
2774+
ExecStart=/usr/bin/find /var/lib/amazon/ssm -mmin +180 -delete
2775+
EOF
2776+
2777+
2778+
2779+
cat <<EOF >/etc/systemd/system/cleanssm.timer
2780+
[Unit]
2781+
Description=Timer for purge old AWS SSM files
2782+
2783+
[Timer]
2784+
OnBootSec=10min
2785+
#OnUnitActiveSec=10min
2786+
RandomizedDelaySec=10min
2787+
2788+
[Install]
2789+
WantedBy=timers.target
2790+
EOF
2791+
2792+
systemctl daemon-reload
2793+
systemctl status cleanssm.timer
2794+
systemctl enable cleanssm.timer
2795+
systemctl stop cleanssm.timer
2796+
systemctl start cleanssm.timer
2797+
systemctl status cleanssm.timer
2798+
2799+
27582800
TODAY=`date '+%Y%m%d-%H%M_%u'`;
27592801
#NOW=`(date "+%Y/%m/%d %H:%M:%S")`
27602802
echo "INFO: ${TODAY} splunkconf-cloud-recovery.sh (version=${VERSION}) end of script run" >> /var/log/splunkconf-cloud-recovery-info.log

0 commit comments

Comments
 (0)