riteshkasat
riteshkasat

Reputation: 803

Running python code as a service on windows server 2012 R2

I have a python script which collects data from Twitter and stores into MongoDb. I need to run this code on the server as a service.

However, only 2 users can remain logged into the server at any given time and therefore If I log out my account, the python script would stop working and data collection will stop.

My question is - How can I run this script as a service on the server such that it keeps running irrespective of whichever user is logged in?

Upvotes: 2

Views: 2110

Answers (1)

James J.
James J.

Reputation: 236

Task Scheduler is the easiest solution I know of. You can use it to run the code at startup as the NT AUTHORITY\SYSTEM user and automatically restart on failure. In case you need it, there's a basic overview of Task Scheduler here.

Upvotes: 1

Related Questions