Don't run a script if another's still running

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Don't run a script if another's still running

Post by Spudwars » Tue Jan 31, 2006 3:16 pm

I'm using Suresync Scheduler to call upon a MS script at midnight using the format:
"c:\dir\msched.exe" c:\dir\runBigScript.scp

This task can take quite a while, and is taking longer each time it is run every night. We have another script (runSmallScript.scp) that is run by Suresync Scheduler on the hour, every hour except 12am and 1am.

As the runBigScript.scp is taking longer, it sometimes eats into our runSmallScript.scp time, and it gets called while the other is still going. This obviously isn't very good, and causes both to fail and in the morning we arrive with a mess - and another few hours processing to catch up on!

We use SureSync because it has a tidy interface for our needs (many many tasks moving many files around the place, and some require the use of runSmallScript.scp on the hour, which it also lets us do).

How can I stop the second macro starting up if the first one is still running? I know you can stop multiple instances of the program, but can you ensure that only one macro is running at a time? Either by holding the runSmallScript or by not letting it run at all?

Thanks for your advice,
Chris.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 31, 2006 3:31 pm

How about make the first script set a flag in an INI file before and after. Have the second script wait for this flag to be reset before continuing:

ScriptA:
EditIniFile>sync.ini,settings,running,yes
..
.. do stuff
..
EditIniFile>sync.ini,settings,running,no

ScriptB:
Label>waitforit
ReadIniFile>sync.ini,settings,running,rflag
If>rflag=yes,waitforit
..
.. continue with script here
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Post by Spudwars » Tue Jan 31, 2006 5:17 pm

Thank you, it's not quite what I thought I was looking for!

I was expecting some sort of external program setting, but using a sync is very sensible! I modified it slightly to use an If statement that then made a log (bigScript still running, exiting script) and then Goto>endscript. This way it won't keep on holding, and will just wait for it's next call!

Thanks once again

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts