Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 732
  • Last Modified:

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.
0
michaelmccomb
Asked:
michaelmccomb
  • 10
  • 6
  • 2
1 Solution
 
sirbountyCommented:
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
0
 
michaelmccombAuthor Commented:
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?
0
 
sirbountyCommented:
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)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
michaelmccombAuthor Commented:
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
0
 
michaelmccombAuthor Commented:
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!
0
 
sirbountyCommented:
no drawbacks, no.
I havent put my finger on the why yet...but glad its working for you...
0
 
Steve KnightIT ConsultancyCommented:
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
0
 
michaelmccombAuthor Commented:
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.
0
 
michaelmccombAuthor Commented:
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.
0
 
sirbountyCommented:
Q: Are you logging off, or is the console being locked?
0
 
michaelmccombAuthor Commented:
i AM logging off and but "locked", not beyond normal passworded login protection...  other jobs do run
0
 
sirbountyCommented:
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...
0
 
Steve KnightIT ConsultancyCommented:
The drive being persistently mapped as E: makes no difference as it is not mapped for the scheduled task.  Add net use e: \\server\share /persistent:no to the top of your script and try again.  You can add credentials to the line if needed, e.g. net use c: \\server\share /user:username password

As an example if you schedule a task to run cmd.exe you should find it knows nothing of the E: drive - if it is the same user account it may, (but I'm not sure), but only if the same user is already logged in at the console.

Steve
0
 
michaelmccombAuthor Commented:
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.
0
 
michaelmccombAuthor Commented:
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

??????

0
 
michaelmccombAuthor Commented:
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
0
 
sirbountyCommented:
*I have made worse boo-boos than that...don't sweat it.
Good luck and have a nice weekend. :^)
0
 
michaelmccombAuthor Commented:
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
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 10
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now