0

I was able to set up a Windows Service through Non-Sucking Service Manager (nssm) in order to run my Python script every 15 minutes. It seems that the service is created and is "running", but there's no indication the script is running. The script and schedule run just fine when I run from the command prompt, so I know there's no issue with my code.

Is there something I'm missing?

import schedule
from time import sleep
from datetime import datetime

def my_func():
    #a bunch of code...
    with open('log.text','a') as outfile:
        outfile.write(f'Program ran at {datetime.now()}')

schedule.every(15).minutes.do(my_func)

while True:
    schedule.run_pending()
    sleep(1)
Walt Reed
  • 1,336
  • 2
  • 17
  • 26

2 Answers2

0

You can enter the following in powershell to see what services are being run

Get-WmiObject win32_service | ?{$_.PathName -like '*nssm*'} | select Name, DisplayName, State, PathName
faro
  • 50
  • 1
  • 7
0

I got similar issue.

My service with a simple script run very smoothly, but with more complexity, it didn’t run. I temporarily use Windows task scheduler to run my big script and it run rather well.

By the way, my timer is (no schedule needed)

While True:
    Mydef()
    time.sleep(300)