Link to home
Start Free TrialLog in
Avatar of michaelmccomb
michaelmccomb

asked on

Task Scheduler not executing a job (starts and instantly stops)

I am attempting to use Task Scheduler on a Server 2003 to do backups to a drive on the network.  The job runs fine if I right click and then click on "run" BUT it does not execute at all from within the Task Scheduler.

The log:
"BackupDBsToKDsMachine.job" (BackupDBsToKDsMachine.bat)
      Started 3/28/2007 2:00:00 AM
"BackupDBsToKDsMachine.job" (BackupDBsToKDsMachine.bat)
      Finished 3/28/2007 2:00:00 AM
      Result: The task completed with an exit code of (0).

The batch job:
cd E:\

robocopy E:\robocopybackup09\ E:\robocopybackup10 /E /w:1 /r:3 /V /XO

rmdir E:\robocopybackup09 /S /Q

rename E:\robocopybackup08 robocopybackup09
rename E:\robocopybackup07 robocopybackup08
rename E:\robocopybackup06 robocopybackup07
rename E:\robocopybackup05 robocopybackup06
rename E:\robocopybackup04 robocopybackup05
rename E:\robocopybackup03 robocopybackup04
rename E:\robocopybackup02 robocopybackup03
rename E:\robocopybackup01 robocopybackup02

md E:\robocopybackup01

cd C:\

robocopy c:\LIVEAccessDBs\ "E:\robocopybackup01" /E /w:1 /r:3 /XD Windows /XD ClientApps /XF Pagefile.sys /XF NTUSER.DAT /V /XO /Purge


The idea is to have a slowly rotating set of backups and renaming is a much quicker option than doing multiple copies that would otherwise be required.  Again, it works with "run" but not via the task scheduler.

I am setting this up via RDT but that shouldn't make any difference right?  Use a member of the admin group as the user name and the correct password for that user.

Several other jobs run during the night with no problem.  None run at the same time.
Avatar of sirbounty
sirbounty
Flag of United States of America image

I think it may be in the way the schedule is setup - try changing the 'run' line in the task to read
cmd /c x:\pathtobatchfile\batchfile.bat
Avatar of michaelmccomb
michaelmccomb

ASKER

i do not understand that suggestion... i am setting this up by going into "task scheduler", browsing to the batch file and then setting up the weekly times that I wish this job to run...  2AM;Tue,Wed,Thr & Fri (a different and weekly runs on Sat), i tell it it wake the computer and ignor all battery considerations... no expiration date on schedule duration

I guess that I do not understand the 'run' line or where to insert the "cmd /c"  is your suggestion related to the dos prompt?
Yes, I've found some batch files that didn't work properly, unless I prefaced them with a call to the command interpreter.
So, open up your task details (Start->Run->%systemroot%\tasks)
Double-click the task, and instead of
"c:\path to file\myfile.bat"
in the run line, use:
cmd /c "c:\path to file\myfile.bat"
(start in can be left blank, or point to %systemroo%\system32)
a half dozen other jobs run (not at the same time) without problem...  one of them repeats every ten minutes from 7AM to 7PM and has no trouble at all...  could some sort of networking delay be responsible for the trouble and is there some way to get the job to pause if that IS the case
thank you, i will try that...  it does seem to be working now...  i rescheduled the task for 1 minute from now after making the change you suggested and it ran...  i'll leave this open until tomorrow to be certain that it runs this evening but as i say it appears that you have fixed my problem....  would sticking in the "cmd /c" be a good thing to do in general (no particular drawbacks/cures problems)?  Thank you very much!
no drawbacks, no.
I havent put my finger on the why yet...but glad its working for you...
BTW if that doesn't work is E: a local drive or drive mapped as the logged in user?  If it is a network drive you might need to add a net use to the top of the script or use the UNC instead.

Steve
DRAT!!!  It did not go.  Same symptom....  starts but then stops instantly.  "net use"???  the network drive it is going to is persistently mapped on the server where the batch job is running.  Having to use "cmd c" would seem redundant so perhaps "net use" would fall into the same category.  None of this seems to make much sense.
I just set the job ahead one minute and then sat there and watched it run exactly as it did yesterday when I ran the test.  So I am asking myself what is wrong with 2:00AM without much of an answer BUT I have now changed the job schedule to run the batch at 3:15AM to see if that fixes the problem.  Something is seemingly very strange here.  Rebooted the server about three days ago just in case something was hosed at a deeper level.
Q: Are you logging off, or is the console being locked?
i AM logging off and but "locked", not beyond normal passworded login protection...  other jobs do run
You're using an admin account, correct?  With network access?
Try using the /IT parameter in your scheduled task (from the command line) - the equivalent, I believe of "Interactive" checkbox in the gui version...
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland 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
Alright  i have now mapped the drive with the "net use e:\\ser..." phrase.  Yesterday the job would run if I was logged in and perhaps that is because the logged in admin user was also the user running the batch job.  Early tomorrow morning the job will run once again with the admin user not interactively logged in.  I did a little test running a batch job via the scheduler one minute later and having the interactive user off... the start and stop times for the batch job were not identical indicating that the job ran successfully.  Back on tomorrow to report on the results for the backup job.
The same error is occuring... zero execution time indicated and nothing is accomplished

***Scheduled Tasks / Advanced / View Log:OutPut***
"BackupDBsToKDsMachine.job" (cmd)
      Started 3/30/2007 2:00:00 AM
"BackupDBsToKDsMachine.job" (cmd)
      Finished 3/30/2007 2:00:00 AM
      Result: The task completed with an exit code of (0).


***BackupDBsToKDsMachine.job / Properties / Run line***
cmd /c "C:\BatchJobs\BackupDBsToKDsMachine.bat"


***Text of batch file***
net use e: \\\\Kevinsws\RoboBackups /persistent:no

cd E:\

robocopy E:\robocopybackup09\ E:\robocopybackup10 /E /w:1 /r:3 /V /XO

rmdir E:\robocopybackup09 /S /Q

rename E:\robocopybackup08 robocopybackup09
rename E:\robocopybackup07 robocopybackup08
rename E:\robocopybackup06 robocopybackup07
rename E:\robocopybackup05 robocopybackup06
rename E:\robocopybackup04 robocopybackup05
rename E:\robocopybackup03 robocopybackup04
rename E:\robocopybackup02 robocopybackup03
rename E:\robocopybackup01 robocopybackup02

md E:\robocopybackup01

cd C:\

robocopy c:\LIVEAccessDBs\ "E:\robocopybackup01" /E /w:1 /r:3 /XD Windows /XD ClientApps /XF Pagefile.sys /XF NTUSER.DAT /V /XO /Purge


Still running perfectly by hand...  right click on task /  run

??????

ok, so i am asking myself what is up with the \\\\ in the "net use" sequence of the run statement.  I do not know how but I MUST be the one who put it in there.... I have now backed it off to only
"net use e: \\Kevinsws\RoboBackups /persistent:no"

it will be over the weekend before I will know if this works
*I have made worse boo-boos than that...don't sweat it.
Good luck and have a nice weekend. :^)
Ok, i've flipped it on and off a couple of times and it seems to be that the "net use" suggestion is the one that straightened things out..  I shall remember this and the "cmd c" line in all future batch jobs