How do I run python code non-stop after user-log-off

Viewed 156

I have a python code implementing a server with API service. I want to run this code endlessly over VM with windows server image. Running the code from command line is stopped after log off. So, the question is how it can be achieved, considering the VM can be logged on and or logged off.

Moreover, how it can be ensured that the code will be re-runned after an unexpexted crush.

In general i am looking to os/python solution and not third part solution.

1 Answers

If you run a console script using pythonw.exe, it will neither display a window nor appear in the task bar. For example:

pythonw.exe scripts/ntlmaps

Be aware, however, that there is no way to interact with the script, nor to terminate it save via the Task Manager.

Related