Is there a python module to indicate if the .py is running?

Viewed 44

I am new to python.

I created a simple Selenium bot that basically runs on a while loop.

However, it runs on an external machine that I do not have access at all times.

It runs into unexpected crashes sometimes, and it takes hours and sometimes days until I check it again only to find a crashed bot. With that said, I'd like to know if a monitoring module or program I can implement into my bot, so I can easily check if the program is running or not.

Some have suggested a WebSocket heartbeat, however, I do not know, after extensive research, how I would go about implementing such an intricate system. Thank you for taking the time to read my question.

Any answers appreciated!

1 Answers

You can just put a few lines of code at the appropriate point in your script (after the Selenium bot completes its work successfully) to write the current date and time into a file.

A second script can be scheduled just to read that file and ring an alarm bell (e.g. send you an email) if it is X hours since the timestamp was last updated.

Alternatively you could write a timestamp to a database table or use whatever other shared systems you have.

Related