I would use a simple lockfile for that.
Lockfiles are usually placed in /run/lock, though that's merely a convention. That directory is destroyed at reboot, so choose a different location if you want persistence.
When the script starts, it creates the lockfile (file creation time = start time)
When the script ends, it logs completion (including start time and end time, if desired) in /var/log and deletes the lockfile.
If the script starts and detects an existing lockfile, you know that a previous instance of the script did not terminate (yet).
If there is no lockfile, previous run was successful.
Bookmarks