SynologyTimedShutdown.sh
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOGFILE="/var/log/synology_timedshutdown.log"
|
||||
touch $LOGFILE
|
||||
|
||||
# Log file #################################################################
|
||||
log () {
|
||||
TIMEDATE=$(date +%Y/%m/%d_%H:%M:%S)
|
||||
echo "$TIMEDATE $1" >> $LOGFILE
|
||||
}
|
||||
|
||||
if [ `cat $LOGFILE | wc -l` -ge 100 ]; then
|
||||
>$LOGFILE
|
||||
log "Log file was rotated"
|
||||
fi
|
||||
############################################################################
|
||||
|
||||
# Main loop ################################################################
|
||||
if [ `ps -ef | grep borgmatic | wc -l` > 1 ]; then
|
||||
log "Triggering scheduled post-backup shutdown"
|
||||
shutdown now
|
||||
exit 1
|
||||
else
|
||||
log "Automatic shutdown cancelled due to concurrent backup task"
|
||||
exit 2
|
||||
fi
|
||||
############################################################################
|
||||
Reference in New Issue
Block a user