aboutsummaryrefslogtreecommitdiffstats
path: root/remove-old-kernels.cron
diff options
context:
space:
mode:
authorBarry Jackson <barjac@users.noreply.github.com>2023-01-05 15:22:25 +0000
committerGitHub <noreply@github.com>2023-01-05 15:22:25 +0000
commit8d6bb61cf2c23bba979716d9cb0ee26789f594bd (patch)
treee228c4131be5bc255a7b2e6a679fdd7c505b2241 /remove-old-kernels.cron
parent7651d383f33ee245a082e657a9055f318f5d6886 (diff)
downloadremove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar
remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.gz
remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.bz2
remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.xz
remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.zip
Add files via upload
initial import
Diffstat (limited to 'remove-old-kernels.cron')
-rw-r--r--remove-old-kernels.cron18
1 files changed, 18 insertions, 0 deletions
diff --git a/remove-old-kernels.cron b/remove-old-kernels.cron
new file mode 100644
index 0000000..df583d8
--- /dev/null
+++ b/remove-old-kernels.cron
@@ -0,0 +1,18 @@
+#!/usr/bin/bash
+
+# cron job to remove old kernels
+# this runs remove-old-kernels to remove old kernels according
+# to the settings in /etc/remove-old-kernels.cfg
+
+if [[ -x /usr/sbin/remove-old-kernels ]]; then
+# Trim log before starting remove-old-kernels with colours disabled
+ if [[ -f /var/log/remove-old-kernels.log ]]; then
+ keeplines=1000; fail=""
+ roktmplog=$(mktemp)
+ ( tail -n $keeplines /var/log/remove-old-kernels.log > $roktmplog && \
+ cat $roktmplog > /var/log/remove-old-kernels.log && rm -f $roktmplog ) || fail="WARNING: log trim failed"
+ fi
+echo -e "\n=========================== $(date +%d/%m/%Y-%H:%M) ===========================\n$fail" >> /var/log/remove-old-kernels.log
+# Use -c option to check that CRON=y is in the cfg file before running in auto mode.
+ /usr/sbin/remove-old-kernels -c -m >> /var/log/remove-old-kernels.log
+fi