Solved

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

Posted on 2007-11-30
10
21,648 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
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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now