Python script started by Task Scheduler can't edit file
I made this python script:
# -*- coding: utf-8 -*-
from datetime import datetime
date = datetime.now()
file = open('myfile.dat', 'a+')
file.write(str(date)+'\n')
It works fine. But when I schedule 开发者_StackOverflow社区it in the Task Scheduler on Windows Server 2008 the script runs, but it doesn't write to the file. Task Scheduler uses my account to run the script so I don't understand why the results are different.
Any idea what I'm missing?
Have you tried using an absolute path to the file?
I think there is also an option in task scheduler to specify where the script should be run, have you set that to the location of the file you want to write to?
精彩评论