How to check a python script ( running or not on windows 10

Home / Uncategorized / How to check a python script ( running or not on windows 10

I’m trying to setup a socket connection between Python and PHP. Python will function as server and PHP as client.

I have a python script ( running form PHP.

how to check this ( is running or not each time before running that from to stop that if this script is running.

how can I check that this script( is running or not in task manager or anywhere else? on windows10.

This is unorthodox, but if you want to handle a basic lock in Windows CMD, you can change your execution line to:dir .lock || echo lock > .lock && python && del .lock

This code will create a lock file if it does not exist, and start the python script. If the lock file already exists it does nothing.

The lock file is deleted after that the python script executed so that you can only have one python script executing at any given time.

You might want to add absolute paths towards the proper python script or the temporary lock folder.

Note that you might have a deadlock situation if the python interpreter runs on an error.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *