I have a Windows Scheduled task that is scheduled to run a python script (.bat file) at 05:30 AM, 01:30PM and 10:30PM daily. The issue is that task scheduler will execute the script at the proper time but when the script pulls time using now = datetime.now()
the hour is 1 hour off. Looking at the datetime settings on the computer appears to be normal and in sync.
Ex: Scheduled task runs at 05:30 but print(now)
will show 06:30. There is a setting on scheduled task triggers that is 'synchronize across time' but that doesn't make a difference in the result. The weird thing is if you manually run the task from windows task scheduler then it will pull the correct times.
I made a simple script for testing purposes in an attempt to troubleshoot but I am stumped.
import os, time
from datetime import date, datetime
def main():
now = datetime.now()
shift = now.strftime('%H')
file = open("timecheck.txt","a")
file.write(f'Time is: {now}\n Shift hour is: {shift}\n\n')
file.close()
main()
The attached screenshot shows the mixmatched results. 12:30 scheduled task results to hour 13:30 but the manual run at 12:37 shows the proper time. Image showing the time discrepancy