Closed gsly closed 1 year ago
Can you describe in more detail what you do, because I can't replicate the same behavior in mine.
root@pve1:~/proxmox-autosnap# ./proxmox-autosnap.py --autosnap --vmid all --label daily --keep 14
VM 104 - Creating snapshot autodaily230219151224
VM 103 - Creating snapshot autodaily230219151226
VM 102 - Creating snapshot autodaily230219151228
VM 101 - Creating snapshot autodaily230219151230
VM 107 - Creating snapshot autodaily230219151232
VM 100 - Creating snapshot autodaily230219151234
VM 100 - Removing snapshot autodaily230211000514
VM 106 - Creating snapshot autodaily230219151242
VM 105 - Creating snapshot autodaily230219151244
root@pve1:~/proxmox-autosnap# echo $?
0
In the meantime, I ran the script several times in another terminal, and everything worked as it was supposed to
root@pve1:~/proxmox-autosnap# ./proxmox-autosnap.py --autosnap --vmid all --label daily --keep 14
Script already running under PID 1947885, skipping execution.
root@pve1:~/proxmox-autosnap# ls
autosnap proxmox-autosnap.py README.md running.pid
root@pve1:~/proxmox-autosnap# ./proxmox-autosnap.py --autosnap --vmid all --label daily --keep 14
Script already running under PID 1947885, skipping execution.
root@pve1:~/proxmox-autosnap# ./proxmox-autosnap.py --autosnap --vmid all --label daily --keep 14
Script already running under PID 1947885, skipping execution.
root@pve1:~/proxmox-autosnap# ls
autosnap proxmox-autosnap.py README.md running.pid
root@pve1:~/proxmox-autosnap# ls
autosnap proxmox-autosnap.py README.md
I updated my script to the latest version this week and I forgot I had opened this issue. I'm running the script via crontab. With the new version of the script, I now correctly get the output you described in your test:
Script already running under PID 3938627, skipping execution.
So I'm guessing this was an issue in previous versions. Sorry for the bother and thanks for the script!
If an instance is running and a second instance starts, it correctly finds the 1st instance's pid file and exits but the finally deletes the pid file. When the 1st instance completes and tries to clean up the pid, it throws exceptions as the file was deleted by the 2nd instance.