If you want to avoid overlapping runs simply simply have the task check for the existence of a lockfile, if not create a lockfile containing the start timestamp, run the task and delete the lockfile at exit or error.

The timestamp gives you a chance to recognize stale/orphraned lock files in case of crashes based on their age.