clean up when exiting

This commit is contained in:
2022-09-30 11:58:48 +02:00
parent b63629de05
commit 89f862c5d8

View File

@@ -4,6 +4,11 @@ source functions.sh
pidfile=/var/run/backup_script
function cleanup {
echo "bye bye"
test -f $pidfile && rm -f $pidfile
}
if [ -f $pidfile ] ; then
pid=$(cat $pidfile)
if [ -d /proc/$pid ] ; then
@@ -48,6 +53,6 @@ mkdir -p $backupdir || myerror 2 "impossible de créer $backupdir"
for dir in "$@" ; do
test -d $dir || { echo $dir dont exist ; continue ; }
echo cp -a $dir $backupdir
sleep 600
done
rm -f $pidfile