I'm not even sure if the lock would work. If the WebApps reload/recycle they might not start simultaneously (at least with 20.0 you have that option now).
A field in the System table might help: you store when you last executed the "startup task". Depending on what you want to execute you could store the time when you last did it or a process ID of a windows process (if you start a program and want to make sure it's still running), etc.

We sometimes use a Windows service, that runs maintenance stuff. Since there is only one instance of the service that might help, but it depends on whether you need to rerun your task if you restart the WebApp.

Regards
Raphael