How do I capture the output of a script if it is being ran by the task scheduler?

前端 未结 9 831
旧巷少年郎
旧巷少年郎 2020-12-02 08:37

Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler?

I\'m testing a rather long custom pr

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 09:25

    You can write to a log file on the lines that you want to output like this:

    @echo off
    echo Debugging started >C:\logfile.txt
    echo More stuff
    echo Debugging stuff >>C:\logfile.txt
    echo Hope this helps! >>C:\logfile.txt
    

    This way you can choose which commands to output if you don't want to trawl through everything, just get what you need to see. The > will output it to the file specified (creating the file if it doesn't exist and overwriting it if it does). The >> will append to the file specified (creating the file if it doesn't exist but appending to the contents if it does).

提交回复
热议问题