Re: Scheduler and Batch Files

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Ernest" <Ernest@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:980BE0DF-14E5-4F22-A534-765ED808A77A@xxxxxxxxxxxxxxxx


"Pegasus (MVP)" wrote:


"Ernest" <Ernest@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:99844F9F-40AB-4481-A819-BA908D35FE69@xxxxxxxxxxxxxxxx


"Pegasus (MVP)" wrote:


"Ernest" <Ernest@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DA48C18E-1152-4D94-9044-8163A1D11C75@xxxxxxxxxxxxxxxx
Let me preface the question by saying what I am trying to
accomplish.
I
have
12 servers that are all running ntbackup at night and storing the
backup
files on the local c:\ drive (the .bkf file). I then have the
scheduler
running a very simple batch file to move the files from the local
drive to
a
mapped share.

Now, 3 of the 12 servers are doing everything as planned (my two
domain
controllers and another server), and the rest show an exit code of
0x1
for
executing the batch file. The actual ntbackups are running fine
and
successfully completing. About 30 minutes to an hour later, when
the
batch
files are running, only 3 complete successfully. I have all 12
staggered
at
different times to prevent a network bottleneck.

When I check the scheduler log, there isn't much more information
than
I
have posted above, and there are no erros in the system,
application,
or
security logs. I get the feeling that I have made a stupid error
with
permissions or mapping, but I am not sure. I mapped the drives
locally,
so
they are user-agnostic, and I am using a generic admin account to
run
the
backups and batch files. I have triple checked to make sure all
of
the
mapping is correct and that the admin has rights to run teh batch
file.
In
addition, if I run the batch file manually by clicking on it, it
runs
fine
every time. I'm sure someone has run across the problem before.
I
appreciate any help.

Let's have a look at your batch file!



Here it is.....

Q:\ is the mapped drive

@echo off
copy C:\dailybackup\*.bkf Q:\ /Y /V
exit


As I had mentioned earlier, it works on 3 of the 12 machines with the
scheduler, and on the rest, it will work when activated manually, just
not
with the scheduler.


Fine. Now modify your batchfile like so:

@echo off
echo %date% %time:~0,5% %UserName% Start of task > c:\test.log

copy C:\dailybackup\*.bkf Q:\ /Y /V 1>>c:\test.log 2>>&1
echo ErrorLevel=%ErrorLevel% >> c:\test.log
echo %date% %time:~0,5% End of task >> c:\test.log

Schedule this batch file on a problem machine, then
have a look at c:\test.log. It is likely that you find the
answer to your problem there.




Ok, went ahead and changed the batch file and had the scheduler run it as
planned.

The output is (without the time/user stamps):

The system cannot find the drive specified.
ErrorLevel=1


I have checked the mapping of the drive several times, and everything
works
fine. It is present, I can save to and from it. I'm not sure what else
could be causing this.

There should be far more text in the log file. I suspect that
you retyped it rather than using copy & paste, and omitted
some redirection charachters in the process. Use the
version below, then post the WHOLE output:

@echo off
echo %date% %time:~0,5% %UserName% Start of task > c:\test.log
net use >> c:\test.log
copy C:\dailybackup\*.bkf Q:\ /Y /V 1>>c:\test.log 2>>&1
echo ErrorLevel=%ErrorLevel% >> c:\test.log
echo %date% %time:~0,5% End of task >> c:\test.log

You will probably find that drive Q: is NOT available,
for the simple reason that your batch file does not map
it. The batch file does not back up anything!

In general it is a bad idea to use mapped drives for scheduled
tasks. The drive letter might not be available, or if it is then it
might not be released for the next scheduled job and thus become
unavailable. Much better to use UNC coding.


.



Relevant Pages

  • Re: Scheduler and Batch Files
    ... "Pegasus (MVP)" wrote: ... When I check the scheduler log, there isn't much more information than ... I mapped the drives ... Schedule this batch file on a problem machine, ...
    (microsoft.public.windows.server.general)
  • Re: Scheduler and Batch Files
    ... 3 of the 12 servers are doing everything as planned (my two ... When I check the scheduler log, ... Schedule this batch file on a problem machine, ... In general it is a bad idea to use mapped drives for scheduled ...
    (microsoft.public.windows.server.general)
  • Re: Mapping a drive automatically
    ... The login script is just a batch file sitting on the server I have ... drives not being availabe for the file transfers. ... I've scheduled a task to execute that batch file on system startup. ... I check the Scheduler log and it ...
    (microsoft.public.windows.server.general)
  • Re: Mapping a drive automatically
    ... The login script is just a batch file sitting on the server I have scheduled ... I need these drives mapped all the time ... I check the Scheduler log and it shows ...
    (microsoft.public.windows.server.general)
  • Re: Backup Utility Not Working
    ... Account used by the scheduled task: Scheduler ... Mapped drives: None ... Run the batch file from the Command Prompt instead of the Task Scheduler. ... As for the contents of the two log files, I could not find a log file ...
    (microsoft.public.windowsxp.general)