I am looking for a simple and generic solution that would allow you to execute any script or application in crontab and prevent it from running twice.
The solution should be independent on the executed command.
I assume it should look like lock && (command ; unlock)
where lock will return false if there was another lock.
The second part would be like if it acquired the lock, run command and unlock after command is executed, even if it returns error.