问题
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:
- Open Task Scheduler in Windows. Control Panel -> Administrative Tools -> Task Scheduler
- Click 'Create Basic Task' (to start the script)
- Set the trigger time
- Set Program/Script =
[full path to python.exe]
- Add Arguments =
[full path to your scheduled python script]
- Click 'Create Basic Task' (to end the script)
- Set the trigger time
- Program/Script =
taskkill /f /im [full path to python.exe]
This guide goes into more detail.
来源:https://stackoverflow.com/questions/46529351/how-to-make-a-windows-scheduler-start-and-stop-a-python-task