[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Windows Server 2008 Task Scheduler Job status shows running after job is done

Posted on 2011-10-25
9
Medium Priority
?
1,108 Views
Last Modified: 2013-11-05
I have a task that runs a .bat file to ftp files from one server to another.  It writes events to the Event log about the progress of the job.  The last event it writes is "Job Completed SUCCESSFULLY".

Following are the last lines of the .bat file.
:END
      eventcreate /t information /id 107 /l application /d "%3.zip Get DB Backup Job Completed SUCCESSFULLY."

:BADEND
      net use %1: /delete
      exit

The problem is that even though the processing of the bat file completes, the job status in Task Scheduler shows running and the next night when the task should run, it doesn't launch because its status is still Running.  

I am thinking about changing the trigger to end job if runs longer than 8 hours, but was wondering if anyone has seen this type of issue before.  The job runs under a local ID with admin privileges.  Sometimes it runs fine and ends other times it remains in a running status until I end it manually.

Any ideas?

Thanks!
0
Comment
Question by:BriantC
  • 4
  • 4
9 Comments
 
LVL 12

Expert Comment

by:Gary Coltharp
ID: 37024652
Why do you not have an exit after your event creation?
0
 

Author Comment

by:BriantC
ID: 37024752
Because I always want to execute the net use %1: /delete command to unmap the source share drive.

I wonder if the net use /delete is prompting for a Y/N response sometimes.  I'll look to see if there is a noprompt option.
0
 
LVL 12

Expert Comment

by:Gary Coltharp
ID: 37024817
I dont know of any Y/N that would occur on a net use /del.... you could try redirecting the output of the lines of your batch file to a log , ie; >>output.log .... then examining the end of it the next day to see if any errors were trapped.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:BriantC
ID: 37025008
Good idea gcoltharp!  Below is the output in the .txt file.  

There are open files and/or incomplete directory searches pending on the connection to M:.

Is it OK to continue disconnecting and force them closed? (Y/N) [N]:

Do you know how I can script a response?  The files have already been copied over, compared, and deleted at this point.  It doesn't always hang, only sometimes.  Can I add /noprompt or something to force it to delete the connection everytime?
0
 
LVL 12

Accepted Solution

by:
Gary Coltharp earned 2000 total points
ID: 37025128
Try adding /yes to the end
0
 
LVL 3

Expert Comment

by:telczj9
ID: 37025781
If that does not work, you can also try:

Echo yes | net use %1: /d

Cheers!
0
 

Author Closing Comment

by:BriantC
ID: 37026254
Thanks gcoltharp!

Redirecting the output to the .txt file identified why the job was hanging and adding the /yes after the net use comand appears to have resolved the issue in my limited testing.
0
 

Author Comment

by:BriantC
ID: 37026269
Thanks also telczj9 for responding.

I will keep your suggestion in case I encounter the same type of hung state in the future.
0
 
LVL 12

Expert Comment

by:Gary Coltharp
ID: 37026275
Awesome! Happy to help!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

834 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