Link to home
Start Free TrialLog in
Avatar of GraemeTL
GraemeTL

asked on

Windows Task Scheduler Stops Task but does not terminate script

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%"
Avatar of Smart_Man
Smart_Man
Flag of Egypt image

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
Avatar of GraemeTL
GraemeTL

ASKER

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.
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
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?
yes


waiting for your reply
I will test
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%=
do you have 2 seperate process running after the solution ?

or one process ?

Only one I think. Yes sure it is only 1 the robocopy
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
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
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
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
ASKER CERTIFIED SOLUTION
Avatar of Smart_Man
Smart_Man
Flag of Egypt 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
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
So easy when you know.  Should have thought of that. Thanks