You can try to create a temporary file, if it is Linux it could be something like /tmp/exe.php.lock, and delete it when processing ends. But there is a great risk that the file will not be removed if PHP fails half way.
Another way is to create a socket on a well-defined, fixed port. If bind () fails it is because another instance has already created the socket on that port and has not yet left. You can refer to the example link to see how to create the socket; just go to bind (), and do not forget socket_close () at the end.
and close the socket when processing stops. The chance of the socket to stay open if PHP fails halfway is less, or perhaps nonexistent.