?
Solved

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

Posted on 2007-11-30
10
Medium Priority
?
21,959 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
Suggested Courses

777 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