Problems running python script by windows task scheduler that does pscp

后端 未结 6 1908
轮回少年
轮回少年 2020-12-08 23:16

Not sure if anyone has run into this, but I\'ll take suggestions for troubleshooting and/or alternative methods.

I have a Windows 2008 server on which I am running s

6条回答
  •  忘掉有多难
    2020-12-08 23:44

    I'm having a similar issue. In testing I found that any type of call with subprocess stops the python script when run in task scheduler but works fine when run on the command line.

    import subprocess
    
    print('Start')
    test = subprocess.check_output(["dir"], shell=True)
    print('First call finished')
    

    When run on command line this outputs:

    Start
    First call finished
    

    When run from task scheduler the output is:

    Start
    

    In order to get the output from task scheduler I run the python script from a batch file as follows:

    python test.py >> log.txt
    

    I run the script through the batch file both on command line and through task scheduler.

提交回复
热议问题