?
Solved

Windows Task Scheduler Stops Task but does not terminate script

Posted on 2008-02-01
16
Medium Priority
?
1,183 Views
Last Modified: 2011-10-03
Hi

As part of an forthcoming upgrade we need to create a duplicate of all our data on our servers.  As to not impact our diffeeriential backups by suddenly increasing the amount of data backed up we wish to schedule a robocopy of the data and back small increments on the run up to the go live.

We have created a simple batch script running robocopy and using windows scheduler have configured the job to only run for 15 mins.  After 15 mins the job terminates but the underlying robocopy process continues to copy the data. In task manager the robocopy process is still running.  Is there a way within our script where we can call robocopy that will enable the task scheduler to terminate all processes called from the script.  Below is copy of our script

Thanks

for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
  for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
  set tm=%tm::=-%
  set dtt=%dt%%tm%
  set dt=%dt%

start robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

mapisend -u servicetsm@scotland.gsi.gov.uk -p " " -r DLCSPTSMA@scotland.gsi.gov.uk -s "VQ65EDER Objective 7 TestDuplicate Doc Store Copy %dtt%"
0
Comment
Question by:GraemeTL
  • 9
  • 7
16 Comments
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20795441
do you want just the process to be terminated regardless it have finished or not. maybe in teh middle of a copy ?


i guess as the scheduler work with teh script . then it terminates teh script and not programs that the script have called.

who long the robocopy will take before ti gets back to the script ?

is your script have the extention *.bat

waiting for your reply
0
 

Author Comment

by:GraemeTL
ID: 20795467
Hi

Firstly the scriot is .cmd.

If the robocopy was to complete it would take several hours due to the volume of data.  We wish the script to terminate even if it is still copying a file. (this includes the robocopy process)  These would be picked up the
 next run.  In the script the mapisend line can be ignored as in theory this should never be reached.
0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20795504
i sorta solved a simillar issue coupel days ago. used a tool to combine exe and bat in a new exe file

that will be the process that you will use in the scheduler. it is sorta a tool for automated setup creation so you can have a silent install by making a new exe out of the old exe + parameters.

the tool is IExpress.exe. google it so you can download it.

waiting for your reply if that solves the problem
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 

Author Comment

by:GraemeTL
ID: 20795653
IExpress sounds interesting. It is on the servers already but how do I configure, do I add the cmd file and robocopy.exe into the package and create and schedule?
0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20795699
yes


waiting for your reply
0
 

Author Comment

by:GraemeTL
ID: 20795814
I will test
0
 

Author Comment

by:GraemeTL
ID: 20796110
Hi

I have created the package by adding the cmd file and the robocopy.exe.  In the package the install program is configured as the script.

When run the new executable from the task scheduler as before it initiates the robocopy.exe process and does not terminate after the task has stopped.  Below is the SED file from the package. I must be doing something wrong

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=0
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=I
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
TargetName=C:\StorageUpgrade\4. Robocopy\RoboCopyPackage.EXE
FriendlyName=RobocopyDocStore
AppLaunched=robocopy.exe
PostInstallCmd=robocopy.exe
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="Robocopydocstore_test.cmd"
FILE1="robocopy.exe"
[SourceFiles]
SourceFiles0=C:\StorageUpgrade\4. Robocopy\
[SourceFiles0]
%FILE0%=
%FILE1%=
0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20796202
do you have 2 seperate process running after the solution ?

or one process ?

0
 

Author Comment

by:GraemeTL
ID: 20796225
Only one I think. Yes sure it is only 1 the robocopy
0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20796273
you may want to check with task manager. watch when it starts. and when it is the termination time.

can you try your scheduler with a more simple process , maybe teh notepad to check if the termination works fine.

how long is the response time when you manually terminate the robocop using the task maneger?

waiting for your reply
0
 

Author Comment

by:GraemeTL
ID: 20796347
Running the package with only the script starts robocopy also (as expected).  After the scheduled task terminates the robocopy process is still running and updating the directories
0
 
LVL 10

Expert Comment

by:Smart_Man
ID: 20796546
i guess you can just start the robocopy with the

robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

as a command like with parameters.  this time the schedule will have no child proccess. and when it is the termination time. it will terminat ethe robocopy.

i do nto see any use for the
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
  for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
  set tm=%tm::=-%
  set dtt=%dt%%tm%
  set dt=%dt%



waiting for your reply
0
 

Author Comment

by:GraemeTL
ID: 20796708
No this does not work either.  I suppose running the script in the package like this is just like calling the script alone.  Is there anyway to call the robocopy process independantly and input the parametors in this package.  

 The other part of the script was for the mapisend function to add date stamps and correctly is not needed
0
 
LVL 10

Accepted Solution

by:
Smart_Man earned 2000 total points
ID: 20796799
as i thought you do not need a script. just few parameters

well then that is too easy. just goto the normal steps to create the scheduled task.
then after u finish . just open the properties window and paste the line with all parameters there, like this

path:\robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

waiting for your reply.
0
 

Author Comment

by:GraemeTL
ID: 20812745
hi

Apologies but I do not follow your advice above.  What job should i be adding to the scheduled task or does this not matter as I will paste over this info

Thanks
0
 

Author Closing Comment

by:GraemeTL
ID: 31427053
So easy when you know.  Should have thought of that. Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

599 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