diff options
author | Roland Reichwein <mail@reichwein.it> | 2022-11-26 12:59:28 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2022-11-26 12:59:28 +0100 |
commit | 7619dc0bef58d00c816b6628e457a85845b9edee (patch) | |
tree | f572b4dd639e0b4b4c0215e1cb1facb299ca0523 /whiteboard-cleanup | |
parent | f116c9146e53d885840ed957204d60d81fd858bd (diff) |
Cleanup via cron/systemd
Diffstat (limited to 'whiteboard-cleanup')
-rwxr-xr-x | whiteboard-cleanup | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/whiteboard-cleanup b/whiteboard-cleanup new file mode 100755 index 0000000..7a987e0 --- /dev/null +++ b/whiteboard-cleanup @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Cleanup global whiteboard files +# +# To be called by cron +# + +set -e + +# look up config file +CONFIGFILE=/etc/whiteboard.conf +XMLLINTOPTS="--nonet --nocdata --nocatalogs" +DATAPATH=`xmllint --xpath "/config/datapath/text()" $XMLLINTOPTS $CONFIGFILE` +MAXAGE=`xmllint --xpath "/config/maxage/text()" $XMLLINTOPTS $CONFIGFILE` + +cd $DATAPATH + +ls -1 | while read i ; do + AGE=$((`date +"%s"` - `stat -c "%Y" $i`)) + if [[ "$AGE" -gt "$MAXAGE" ]] ; then + echo "Deleting entry $i ..." + rm $i + fi +done |