How to make a windows scheduler Start and Stop a p

2019-08-22 11:49发布

问题:

I have a python script that I typically kick off manually. It then runs for several days collecting information until it gets disconnected.

What I want to do is have the Windows scheduler start the job 12:01 AM and then terminate the job at 11:58 pm that same day.

Typically I would be able to do this using CRON in the linux world but am unsure how to do this in Windows Scheduler.

Thank you for your help!

回答1:

  1. Open Task Scheduler in Windows. Control Panel -> Administrative Tools -> Task Scheduler
  2. Click 'Create Basic Task' (to start the script)
  3. Set the trigger time
  4. Set Program/Script = [full path to python.exe]
  5. Add Arguments = [full path to your scheduled python script]
  6. Click 'Create Basic Task' (to end the script)
  7. Set the trigger time
  8. Program/Script = taskkill /f /im [full path to python.exe]

This guide goes into more detail.