I'd like to delete a lock file if I reboot or shutdown my Ubuntu 18.04.4.
I created "usr/local/sbin/delete_lock.sh" with
#!/bin/bash lock="/home/sebastien/rsync.lock" if [ -f "$lock" ]; rm $lock; fi
and then another "/etc/systemd/system/run_on_shutdown.service":
[Unit] Description=Delete lock file at shutdown - /etc/systemd/system/run_on_shutdown.service DefaultDependencies=no Before=shutdown.target halt.target # If your script requires any mounted directories, add them below: RequiresMountsFor=/home [Service] Type=oneshot ExecStart=/usr/local/sbin/delete_lock.sh [Install] WantedBy=halt.target shutdown.target
then I launch
sudo systemctl enable run_on_shutdown.service
Any idea why the rsync.lock file isn't deleted ? Many thanks