ytjPerl has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone had problem with scheduling perl script as windows task scheduler? at my end, the script is working fine if I manually run it, but I could not get the result when it is running on scheduler.
  • Comment on schedule perl script on windows task scheduler

Replies are listed 'Best First'.
Re: schedule perl script on windows task scheduler
by pryrt (Abbot) on Nov 27, 2017 at 21:27 UTC

    I use Task Scheduler at home with a daily scheduled task, and it works fine for me. Since you give my few details, it's hard to guess what's going wrong, but the things I would look at:

    • Task Scheduler: Last Run Result => should give exit status for the last run
    • In the Actions | Edit Action dialog:
      • "Program/Script:" c:\full\path\to\perl.exe = Task Scheduler doesn't necessarily know the PATHs you think it does
      • "Add arguments (optional):" to c:\full\path\to\script\filename.pl = Task Scheduler needs to know where the script lives
      • "Start In (optional):" to c:\full\path\to\script = If this is skipped, relative paths in your script won't be relative to your filename.pl's location
    • If that wasn't enough, use error logging to a hardcoded file (open my $fh, '>', '' or die $!; ... print $fh "messages\n"; ...) or using Log::Any, or redirect STDERR (look in open and search for "redirect"), which will get error messages to a known location, so you can figure out what's going on.

    The more details you provide, the better we can help you: see I know what I mean. Why don't you? and SSCCE

    update 1: fixed typo: s/my/few; thanks LanX

Re: schedule perl script on windows task scheduler
by thanos1983 (Parson) on Nov 28, 2017 at 09:40 UTC

    Hello ytjPerl,

    Have you tried the Win32::TaskScheduler?

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
A reply falls below the community's threshold of quality. You may see it by logging in.