Link to home
Start Free TrialLog in
Avatar of WillEastbury
WillEastbury

asked on

Task Scheduler batch file exiting with : "Result: The task completed with an exit code of (ff)."

I have a .bat batch file scheduled under Task Scheduler that is basically exiting for no discernable reason ...

It should be run at 11pm, looping indefinitely for 23 hours, then should get killed by the "Stop task if it runs for 23 hours" setting in the task.

It then gets rescheduled 1 hour later (11pm again), ad infinitum.

The task seems to run till round about 1:30am, and then falls over.

The task scheduler error log shows the following :-

"Online Backup Script.job" (archivemaster.bat)
Started 05/12/2005 23:00:03

"Online Backup Script.job" (archivemaster.bat)
Finished 06/12/2005 01:16:30
Result: The task completed with an exit code of (ff).

Now, if the file completed OK, I would expect to see this :-

"Online Backup Script.job" (archivemaster.bat)
Finished 08/12/2005 11:57:09
Result: The task completed with an exit code of (0).

Or if the file exceeded it's runtime, then this :-

"Online Backup Script.job" (archivemaster.bat) 02/11/2005 18:15:02 ** WARNING **
The task was forced to close since its execution time exceeded the configured maximum.
You may want to go to the Settings page and increase the "Stop the scheduled task after" time.

Or if someone killed the job, then this :-

"Online Backup Script.job" (archivemaster.bat) 29/11/2005 10:05:52
** WARNING ** The task was terminated. This action was initiated either by an administrator or by the Task Scheduler service (because, for example, the computer is now non idle).

I've done the usual googling / kb searches, looked on Technet and MSDN also, but can't find this anywhere :- so here's 500 pts available for the challenge.

Can someone elaborate what this Task Scheduler exit code ff is and possibly help to fix the failing scripts (Which are below) ?

REM *********************************************************************************************************
REM archivemaster.bat

:start
CLS
rem Backup schedule restarting

f:
cd f:\backup schedule

rem master full backup (0 mins)
call archivebak.bat AF_Live
call archivebak.bat cindercone_magma_accantia
call archivebak.bat csmaster
call archivebak.bat sagelive1
call archivebak.bat sagelive2
call archivebak.bat sagelive3

sleep 600

rem 10 minutes later .. differential backup #1
call archivedif.bat AF_Live
call archivedif.bat cindercone_magma_accantia
call archivedif.bat csmaster
call archivedif.bat sagelive1
call archivedif.bat sagelive2
call archivedif.bat sagelive3

sleep 600

rem 10 minutes later .. differential backup #2
call archivedif.bat AF_Live
call archivedif.bat cindercone_magma_accantia
call archivedif.bat csmaster
call archivedif.bat sagelive1
call archivedif.bat sagelive2
call archivedif.bat sagelive3

rem 10 minutes later .. differential backup #3

call archivedif.bat AF_Live
call archivedif.bat cindercone_magma_accantia
call archivedif.bat csmaster
call archivedif.bat sagelive1
call archivedif.bat sagelive2
call archivedif.bat sagelive3

rem 10 minutes later .. differential backup #4

call archivedif.bat AF_Live
call archivedif.bat cindercone_magma_accantia
call archivedif.bat csmaster
call archivedif.bat sagelive1
call archivedif.bat sagelive2
call archivedif.bat sagelive3

rem 10 minutes later .. differential backup #5

call archivedif.bat AF_Live
call archivedif.bat cindercone_magma_accantia
call archivedif.bat csmaster
call archivedif.bat sagelive1
call archivedif.bat sagelive2
call archivedif.bat sagelive3

goto start

REM *********************************************************************************************************
REM archivebak.bat

cls
ISQL -S SQLCLUS -U sa -P ******** -Q "BACKUP DATABASE [%1] TO  DISK = N'F:\Backup Schedule\%1.bak' WITH INIT ,  NOUNLOAD ,  NAME = N'%1 Hourly Full DB Backup',NOSKIP,STATS = 10,  NOFORMAT"

path %Path%;C:\Program Files\WinZip;D:\Program Files\Resource Kit

F:\

CD "F:\BACKUP SCHEDULE\"

NET USE y: \\125.44.120.11\dr /U:***domain\****account *********

WzZip -a+ -es y:\%1bak.zip %1.bak

time /t > y:\%1bak.act

net use y: /delete


REM *********************************************************************************************************
REM archivedif.bat

cls

ISQL -S SQLCLUS -U sa -P ******** -Q "BACKUP DATABASE [%1] TO  DISK = N'F:\Backup Schedule\%1.dif' WITH INIT ,  NOUNLOAD ,  NAME = N'%1 10 Minute Differential DB Backup',NOSKIP,DIFFERENTIAL,STATS = 10,  NOFORMAT"

path %Path%;C:\Program Files\WinZip;D:\Program Files\Resource Kit

F:\

CD "F:\Backup Schedule"

cls

time /t

NET USE y: \\125.44.120.11\dr /U:***domain\****account *********

wzzip -a+ -es y:\%1dif.zip %1.dif

time /t

time /t > y:\%1dif.act

net use y: /delete

Avatar of sirbounty
sirbounty
Flag of United States of America image

first thing that jumps out at me is

cd f:\backup schedule

should read:
cd "f:\backup schedule"
or
cd f:\backup~1


Another thing that I see may be either network timeouts or simply mapping problems:

NET USE y: \\125.44.120.11\dr /U:***domain\****account *********

perhaps preceed this with a
net use y: /del
Avatar of WillEastbury
WillEastbury

ASKER

"f:\backup schedule" : Noted, but the script runs correctly the first few runs, the cd isn't really needed anyway, as the process is launched with the working directory set to f:\backup schedule anyway.

And the "net use y: /delete" is in there, but it happens AFTER the work is done on the remote drive.

I'm really looking for an explanation of the exit message from task scheduler.

Will make the changes anyway and see if it helps though ...

Thanks,
Will
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent, I didn't know about that little trick ...

As Requested. As you can see it's this bloody last result 255 again (or hex ff) ! ! !

HostName:                             SAGECLUS01
TaskName:                             Online Backup Script
Next Run Time:                        23:00:00, 08/12/2005
Status:                              
Logon Mode:                           Interactive/Background
Last Run Time:                        23:00:00, 07/12/2005
Last Result:                          255
Creator:                              administrator
Schedule:                             At 23:00 every day, starting 28/11/2005
Task To Run:                          F:\Backup Schedule\archivemaster.bat
Start In:                             F:\Backup Schedule
Comment:                              N/A
Scheduled Task State:                 Enabled
Scheduled Type:                       Daily
Start Time:                           23:00:00
Start Date:                           28/11/2005
End Date:                             N/A
Days:                                 Everyday
Months:                               N/A
Run As User:                          **DOMAIN**\ADMINISTRATOR
Delete Task If Not Rescheduled:       Disabled
Stop Task If Runs X Hours and X Mins: 23:0
Repeat: Every:                        Disabled
Repeat: Until: Time:                  Disabled
Repeat: Until: Duration:              Disabled
Repeat: Stop If Still Running:        Disabled
Idle Time:                            Disabled
Power Management:                     No Start On Batteries, Stop On Battery Mode
Also , I've made a slight change re : the way that the path environment variable is set, cause it would be huge the way it's being done now !

Basically I've moved the path setup to the start of the first batch file.

Thanks,
Will
So, you're scheduling this via control panel, I presume.
Personally, I prefer using the command line version, as you have more control over it.

Question - when these three run, should they all assume the same network credentials?
Is it being run outside of a particular logon session?
Via control panel ...

They are all logging on as the Domain administrator account for that domain.

They are mapping a drive as another domain's administrator account (The remote machine is in another isolated domain with no trust relationship defined.

I've changed the schedule to do this now, so I can get the output of the scripts to a text file and grab any error (Or at least see WHERE it falls over)  :-

REM ********************************************************
REM : Run this script but output the results to a file. . .
REM ********************************************************

f:
cd "F:\Backup Schedule\"

if exist "F:\Backup Schedule\ArchiveLog.old" DEL "F:\Backup Schedule\ArchiveLog.old"

ren ArchiveLog.txt ArchiveLog.old
 
"F:\Backup Schedule\ArchiveMaster.bat" > "F:\Backup Schedule\ArchiveLog.txt"

You're not running these through a terminal session are you?
I don't know if you're interested, but here's a rather shorter, single batch file suggestion:

REM archivemaster.bat
setlocal

:start
CLS
set path %Path%;C:\Program Files\WinZip;D:\Program Files\Resource Kit
set parms=AF_Live cindercone_magma_accantia csmaster sagelive1 sagelive2 sagelive3
NET USE Y: /del
NET USE y: \\125.44.120.11\dr /U:***domain\****account *********

rem Backup schedule restarting

f:
cd "\backup schedule"

rem master full backup (0 mins)
call :fullbkup %parms%

:diffLoop
ping 125.44.120.11 -n 600
call :diffbkup %parms%
set /a ctr=%ctr%+1
if %ctr% LEQ 5 goto diffLoop
goto :eof

:fullbkup
ISQL -S SQLCLUS -U sa -P ******** -Q "BACKUP DATABASE [%1] TO  DISK = N'F:\Backup Schedule\%1.bak' WITH INIT ,  NOUNLOAD ,  NAME = N'%1 Hourly Full DB Backup',NOSKIP,STATS = 10,  NOFORMAT"
WzZip -a+ -es y:\%1bak.zip %1.bak
echo Full backup completion occurred at %time% > y:\%1bak.act
::If no more parameters record the completion time and exit, otherwise continue with the next parameter
shift
if not [%1]==[] goto fullbkup
goto :eof

:diffbkup
ISQL -S SQLCLUS -U sa -P ******** -Q "BACKUP DATABASE [%1] TO  DISK = N'F:\Backup Schedule\%1.dif' WITH INIT ,  NOUNLOAD ,  NAME = N'%1 10 Minute Differential DB Backup',NOSKIP,DIFFERENTIAL,STATS = 10,  NOFORMAT"
wzzip -a+ -es y:\%1dif.zip %1.dif
echo Differential backup #%ctr% comlpetion occurred at %time% > y:\%1dif-%ctr%.act
shift
::If no more parameters record the completion time and exit, otherwise continue with the next parameter
if not [%1]==[] goto archivedif
goto :eof
Interestingly ... if I run it through a terminal services session it works perfectly . . . .

If I go to the console and run it manually it works fine.

If I execute the schedule via the control panel applet it works ok.

When the schedule kicks off via the task scheduler service at 23:00 it bombs out at around 1:30 am

It's the whole 1am ish thing that's getting me !

Here's an example dir of the target folder from this morning (This is on the other machine, that hosts the Y: drive as F:\Backup Schedule, there's an unzip process that runs when the .act file is created for each database.)

 Volume in drive F is Ext Data
 Volume Serial Number is F4B7-F998

 Directory of F:\Backup Schedule

08/12/2005  01:30    <DIR>          .
08/12/2005  01:30    <DIR>          ..
25/11/2005  15:34                 7 1-servicesdown.txt
08/12/2005  01:33       354,073,088 AF_Live.bak
25/11/2005  15:42             5,681 Apply.bat
08/12/2005  01:34        57,098,752 cindercone_magma_accantia.bak
08/12/2005  01:34        50,022,912 csmaster.bak
08/12/2005  07:30                 0 DIRECTORYLIST.TXT
29/11/2005  10:08               559 Extract.bat
29/11/2005  10:05               262 extractspool.bat
08/12/2005  01:05     1,564,978,688 SAGELIVE1.bak
08/12/2005  01:32           306,688 SAGELIVE1.dif
08/12/2005  01:11        61,950,464 SAGELIVE2.bak
08/12/2005  01:32           215,552 SAGELIVE2.dif
08/12/2005  01:11        38,160,896 SAGELIVE3.bak
08/12/2005  01:32           215,552 sagelive3.dif
18/04/2003  17:06             5,120 sleep.exe
06/10/2005  14:38               622 unarchive.bat
08/12/2005  01:30                33 WZUNZIP.bat
              17 File(s)  2,127,034,876 bytes
               2 Dir(s)  31,082,684,416 bytes free
Is anyone logged on to the ts when it runs?  I believe there is a known problem in this particular setup...
What is the known problem ?

We are running Windows Server 2003 SP1

Also,that point leads me to believe that the known problem is the one which generates a code 80 (not ff)

I think this might be the FF Error : ERROR_EA_LIST_INCONSISTENT (255) The extended attributes are inconsistent.

The winzip part seems to be exiting out with the ERROR_EA_LIST_INCONSISTENT error code.

God knows why, but those changes now seem to be keeping the script running ok, it's only crashed once in the last 5 days, and that was 5 days ago.

Even if the question really hasn't been fully answered, I think you have been a huge help to me in resolving the problem, and I thank you for your assistance.

Also, I appreciate the single batch file suggestion, and the scheduler tip you provided.

As to that, you can have the points and an A grade even though the question hasn't been totally answered.

Once again, thanks for your assistance.

Will Eastbury