I want to schedule a python script using the python-crontab module on Windows platform. Found the following snippet to work around but having a hard time to configure. Script name cronTest.py:
from crontab import CronTab
file_cron = CronTab(tabfile='filename.tab')
mem_cron = CronTab(tab="""
* * * * * command
""")
Let's say, for example, I want to print date & time for ever 5 mins using the following script, named dateTime.py:
import datetime
with open('dateInfo.txt','a') as outFile:
outFile.write('\n' + str(datetime.datetime.now()))
How do I execute dateTime.py and setup the cron job for every 5mins through cronTest.py.
*/5 * * * * <PATH_TO_PYTHON> <PATH_TO_dateTime.py>in place of* * * * * commandand runningcronTest.pyagain?commandwith path to my script it didn't work, I guess I need to know what exactly I should pass totabincron = CronTab(tab=""" */5 * * * * python <path to script>""") my_cron=cron.new(command='python D:\Pyhon\currentDate.py') my_cron.minute.every(1)pythonin your crontab.