Closed kapitainsky closed 5 years ago
My Bash is a bit rusty. Could you explain the difference between the previous code and the new one?
Your code asks the system for all pids of processes with name like the script. Then you compare it to single pid from inprogress file. Which means that if there is more than one backup running your lock never works as condition is never met - you compare single number to the list of numbers.
I changed it to ask the system to provide the name of the specific process (with pid from inprogress file). Then I check if it is the script name.
That makes sense, thanks for clarifying.
Existing lock does not work as pgrep can return multiple pid (if other backups are running) and in this case condition to abort won't be met. It will also happen when backup is run locally (e.g. to another filesystem) as in this case rsync spawns two processes.