【问题标题】:Output redirects are not working running Perl program via Windows Task Scheduler输出重定向无法通过 Windows 任务计划程序运行 Perl 程序
【发布时间】:2018-07-18 18:36:10
【问题描述】:

我已将 Perl 脚本配置为通过 Windows 任务计划程序定期运行。

Action: Start a program
Program: C:\Perl64\bin\perl.exe
Add arguments: script.pl config.json > output.txt 2>&1
           or: script.pl config.json 2>&1 > output.txt
Start in: c:\path\to\scriptPL\

程序运行,但它在$ARGV[1] 中获得>2>&1,而不是重定向输出。从命令提示符运行时,输出重定向工作。

我错过了什么?

【问题讨论】:

  • 我知道,在您的情况下,您指定了“开始于”目录 - 但它的默认值是空的 - 所以很容易丢失它 - 并且有一个像我这样的案例,其中文件我正在重定向到实际上最终位于 C:\Windows\System32 - 只是给可能正在搜索类似案例的其他人的注释......

标签: perl scheduled-tasks taskscheduler output-redirect


【解决方案1】:

输出重定向may or may not work with the Task Scheduler。解决方法是在批处理文件中运行所需的命令(包括输出重定向),然后从任务计划程序调用批处理文件。

script.bat
----------
C:\Perl64\bin\perl.exe script.pl config.json > output.txt 2>&1

【讨论】:

    猜你喜欢
    • 2015-08-08
    • 2021-01-21
    • 2012-08-30
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    • 2021-09-17
    • 2019-12-07
    • 1970-01-01
    相关资源
    最近更新 更多