Below is the code which I am using (in windows(administrator mode)):
my $jobs=`bjobs -w | tr -s " " | cut -d " " -f7 | tail -n +2 | sort -u | grep -i "_PV_"`; ## Find out all the jobs running on cmd
print "$jobs is jobs\n";
my @jobsArray = split("\n", $jobs);
When running via command line, no issue is coming .(##cygwin is installed on my system)
But, when scheduling the task via task scheduler and running, below issue is coming:
-uThe system cannot find the file specified.
tail: write error
is jobs
How to get rid of this error?
Problem solved by adding a valid path (with no permission issue) in "start in" option of task scheduler
With no path in "start in" of task scheduler, as script was running in administrator mode, default path in cmd would be coming "C:\Windows\System32"
which might be having some permission issue. Adding "start in" path in task of task scheduler solved the problem as it changed the directory, which opens up in a default admin cmd, to a valid (permission error free) path (like, cd "C:\\Users"
).