Re: Windows 2008 Scheduled Tasks
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Thu, 18 Dec 2008 19:54:57 +0100
Thanks for the feedback.
By the way, I never wrote "2>>$1" - I wrote "2>>&1". The difference is
crucial for the debugging effort and it would have highlighted the error
caused by the trailing spaces. I should have warned you not to retype my
code but to copy/paste it - it's much more efficient anyway!
"Joe Grover" <grover.joe@xxxxxxx> wrote in message
news:OrE85jTYJHA.5476@xxxxxxxxxxxxxxxxxxxxxxx
Well... um... It completed successfully. No error.
However, thanks to me playing with the script you posted I think I've
found the problem.
Originally when I put your script in there I didn't edit it so the "2>>$1"
command was on the same line as the Copy command, so the task failed with
a new error (0xFF) and the text file only said "1 file copied", which was
likely the log file. I changed it and ran it again and it completed
successfully.
I then went back into my original script and I saw that the second Copy
command had a space at the end of the string. I started looking at other
scripts I had problems with and found similar issues in those (these are
not scripts I've created, just ones that have been running without issue
on an older server for time beyond counting that I copied over to this new
2008 machine). Apparently 2008 is less tolerant of these trailing spaces
(at least when running at ask, as the scripts work fine if you just
execute them manually).
I deleted this trailing space, rescheduled the task to run and it
completed successfully. Thanks!
"Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message
news:uKWe%239HYJHA.2280@xxxxxxxxxxxxxxxxxxxxxxx
"Joe Grover" <grover.joe@xxxxxxx> wrote in message
news:eG2kdvHYJHA.4852@xxxxxxxxxxxxxxxxxxxxxxx
Man, I just don't know what it is that's so different in 2008 that's
giving me such headaches with scheduled tasks.
Since converting from a Windows 2003 server to 2008 for our file server
I've had numerous problems with scheduled tasks no longer running. I've
set them up as identically as I can tell (given the differences between
the two task scheduler interfaces), running the same script files, and
they just don't want to run on the 2008--but only as a scheduled task.
If I run the .cmd from the command line it works fine.
For example:
I have a basic script (estimating.cmd) that uses the Windows copy
command to copy two Excel documents from a departmental share to our
intranet site. The script is as follows:
Copy "C:\DATA\estimate\Resource Tools\HardBids.xls"
"\\lan-intranet\c$\Inetpub\wwwroot\ProjectPlanningGroup"
Copy "C:\DATA\estimate\Resource Tools\CurrentEstimatLoad.xls"
"\\lan-intranet\c$\Inetpub\wwwroot\ProjectPlanningGroup"
Both the file server (that the script is running on) and the intranet
server are domain members, and the task is running using the domain
administrator account. I've also tried checking the "Run with highest
privileges" box. If I go to the command prompt, navigate to the scripts
director and type "estimate.cmd", the script runs fine, both files are
copied successfully. If I set this up as a scheduled task it fails with
result 0x1. I am unable to determine what this error means for the copy
command, and it just boggles my mind why it would fail in the first
place, since running the script manually works without a problem.
I've tried using the /Y switch in case whatever environment is running
the script just doesn't like the fact that the file already exists at
the destination. I've also tried adding > ppg.log at the end of the
first line and >> ppg.log at the end of the second to record some sort
of output, but no files were created.
I welcome any advice, as I'm at my wit's end here. The other scripts
I've just given up and ran them from the target, copying from the source
to themselves, but I would like to nail down once and for all just what
is so different about the Windows 2008 Task Scheduler that is causing
every script I've ever used to not run without issue. Thanks in
advance.
Joe
Standard solution: Give yourself some eyes so that you can see what's
going on. Here is the modified version of your batch file:
@echo off
echo %date% %time% %UserName% %ComputerName% >> c:\test.txt
Copy /y "C:\DATA\estimate\Resource Tools\HardBids.xls"
"\\lan-intranet\c$\Inetpub\wwwroot\ProjectPlanningGroup" 1>>c:\test.txt
2>>&1
Copy /y "C:\DATA\estimate\Resource Tools\CurrentEstimatLoad.xls"
"\\lan-intranet\c$\Inetpub\wwwroot\ProjectPlanningGroup" 1>>c:\test.txt
2>>&1
echo %date% %time% End of task >> c:\test.txt
Note that the /y switch belongs into the batch file if you want it to be
robust, not into the environment.
Now examine c:\test.txt and all will become clear.
.
- Follow-Ups:
- Re: Windows 2008 Scheduled Tasks
- From: Joe Grover
- Re: Windows 2008 Scheduled Tasks
- References:
- Windows 2008 Scheduled Tasks
- From: Joe Grover
- Re: Windows 2008 Scheduled Tasks
- From: Pegasus \(MVP\)
- Re: Windows 2008 Scheduled Tasks
- From: Joe Grover
- Windows 2008 Scheduled Tasks
- Prev by Date: Re: Process Explorer crash system (on TCP tab)
- Next by Date: Re: rename file in system folder
- Previous by thread: Re: Windows 2008 Scheduled Tasks
- Next by thread: Re: Windows 2008 Scheduled Tasks
- Index(es):
Relevant Pages
|