Solved

Scheduled task in Windows server 2003 returns 0x2 and doesn't seem to run batch file

Posted on 2007-11-30
10
21,822 Views
Last Modified: 2013-12-01
I am running 2 scheduled tasks on a Windows 2003 server. Each of these calls a separate batch file to run various backup and database maintenance processes on a  Mimer SQL database. These have both been working correctly for months. In the last 3 days they have stopped working.

When I run the batch files manually (in explorer) they complete everything correctly. When they are set to run as scheduled they do not complete the tasks and return last result 0x2.

I have looked up this code and believe it to mean: ERROR_FILE_NOT_FOUND 2 The system cannot find the file specified. From http://msdn2.microsoft.com/en-us/library/ms681382.aspx 

Ive checked the paths and all looks OK. What can this mean?


 
0
Comment
Question by:jamesd84
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20387323
If you are using mapped drives they might not be available. I'd suggest using URNs:

\\server\share\dir
0
 

Author Comment

by:jamesd84
ID: 20387327
Thanks for your response, both batch files are local to the server.
0
 
LVL 17

Accepted Solution

by:
JohnGerhardt earned 250 total points
ID: 20387364
Have you considered just recreating the tasks...? Often this can solve the problem, quickly and simply!
Hope this Helps
-Jaggie
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 30

Expert Comment

by:SteveGTR
ID: 20387986
Can you post 1 of the batch files?
0
 

Author Comment

by:jamesd84
ID: 20390175
I have re-created both tasks - thanks for that suggestion John. Ive just got a funny feeling that it is scheduled tasks bug, because after I re-created the tasks and ran them, the scripts ran and the backup was successful - but it still exited with 0x2. Thoughts?

Here is one of the batch files

**START

CD\OASIS824CM
 
REM - Delete all dbc and log files in the backup folder
DEL C:\OASIS824CM\backup\*.dbc
DEL C:\OASIS824CM\backup\*.log
 
REM - Set database offline/online to clear cache
BSQL OASIS824CM <OFFLINE.TXT
BSQL OASIS824CM <ONLINE.TXT
 
REM - Stop Mimer Database
NET STOP MIMER-OASIS824CM
MIMCONTROL -t OASIS824CM
 
REM - Perform  physical checks on system databank
DBC C:\OASIS824CM\data\sysdb92.DBF C:\OASIS824CM\backup\sysdb92.DBC
REM - Restart Mimer Database
NET START MIMER-OASIS824CM
MIMCONTROL -s OASIS824CM
 
REM - Force Database Online Again in case of errors
BSQL OASIS824CM <ONLINE.TXT
 
REM - Call Utils to verify database
xcopy C:\OASIS824CM\oasis8.ini C:\oasis8\oasis8.ini /y /e /h /c
C:\OASIS824CM\UTILS82E [VERIFY]
 
REM - If Utils writes a flag file then drop out
If exist C:\OASIS824CM\backup\DBC.LOG goto :EOF
 
REM - Delete all dbf files in backup directory
DEL C:\OASIS824CM\backup\*.dbf
 
REM - Stop Mimer Database and Dos Copy Files
NET STOP MIMER-OASIS824CM
MIMCONTROL -t OASIS824CM
XCOPY C:\OASIS824CM\log\*.DBF C:\OASIS824CM\logarch1 /y /e /h /c /i
COPY C:\OASIS824CM\data\*.DBF C:\OASIS824CM\log
 
REM - Restart Mimer Database
NET START MIMER-OASIS824CM
MIMCONTROL -s OASIS824CM
 
REM - Perform an online backup
BSQL OASIS824CM <OBACKUP.TXT
 
 
REM - Force Database Online Again in case of errors
BSQL OASIS824CM <ONLINE.TXT

**END
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20390436
One thing you might do is alter your initial cd command to this:

CD /D C:\OASIS824CM

Other than that it looks good to me. The only thing I can think is that the last BSQL command is returning the code. You could dump some debugging information:

BSQL OASIS824CM <ONLINE.TXT
(echo [%date% %time%] Errorlevel: %errorlevel%)>>debug.txt

0
 
LVL 32

Expert Comment

by:r-k
ID: 20399217
Anything of interest in the Scheduler log?
(Scheduled Tasks -> Advanced -> View Log)
0
 

Author Comment

by:jamesd84
ID: 20402094
Thanks everyone for your input - im kicking myself. After re-creating the tasks it is working again. Lots of other scheduled tasks were created by another tech - maybe this had something to do with it. Does scheduler have a bug of this nature??
0
 

Author Closing Comment

by:jamesd84
ID: 31412083
Thanks a heap John - sometimes the simplest thing hey ;)
0
 

Expert Comment

by:mservidio
ID: 32356232
I was receiving the same 0x2 error message when trying to execute a batch script that used mapped network drives. Once I removed mapped network drives, and specified the full patch \\machine\folder, ie... it works.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question