2020-08-18 11:57:53 +02:00
|
|
|
#!/bin/bash
|
2021-03-07 19:40:32 +01:00
|
|
|
{{ file_header | default () }}
|
2020-08-18 11:57:53 +02:00
|
|
|
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
|
|
|
|
LOCKDIR=${HOME}/.cache
|
|
|
|
# Get an exclusive lock or exit
|
|
|
|
function exlock() {
|
|
|
|
exec {lock_fd}>${LOCKDIR}/$(basename $0).lock
|
|
|
|
flock -nx "$lock_fd"
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
# Cleanup lock file and exit
|
|
|
|
function unlock() {
|
|
|
|
rm "${LOCKDIR}/$(basename $0).lock"
|
|
|
|
[[ -n $1 ]] && exit $1
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Damit prueft ob das Script ob es schon laeuft
|
|
|
|
exlock
|
|
|
|
|
|
|
|
(
|
2020-11-12 14:46:27 +01:00
|
|
|
echo "--------------------------------------------------"
|
2021-01-10 16:10:24 +01:00
|
|
|
echo $(date +%d.%m.%Y-%T) sanoid start
|
2020-11-12 14:46:27 +01:00
|
|
|
echo ""
|
|
|
|
/usr/local/bin/sanoid --cron --verbose
|
|
|
|
echo ""
|
2021-01-10 16:10:24 +01:00
|
|
|
echo $(date +%d.%m.%Y-%T) sanoid end
|
2020-08-18 11:57:53 +02:00
|
|
|
) >> /var/log/sanoid-cron.log 2>&1 &
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Hiermit wird die Lockdatei geloescht
|
|
|
|
unlock
|