Jump to content
Macro Express Forums

Run a macro every minute but don't run it if it's already running


Recommended Posts

Hi,

I have a macro that is scheduled to run every minute, it executes a batch script and it takes sometimes more than 1 minute to complete. I don't want the macro to run again if it's already running. How can I achieve that ?

Related question : is there a way to wait for a command (the batch script) to terminate before continuing the macro ?

Link to comment
Share on other sites

Didn't you already ask the first question in another thread?  I believe the answer was, the scheduled macro will not run again if the previous instance is still running.  I would recommend you do some testing to make sure that is true.   

For your related question, this should work:

1) When your macro starts, create a temp file -- let's call it marker.txt.

2) Start the batch script.

3) Use a Repeat loop to check over and over for the existence of marker.txt.  Do not exit from the Repeat loop as long as the file exists.  Somewhere inside the Repeat loop, include a few seconds delay -- this is just so looping won't chew up so much processor time.
 
4) As the last step in your batch script, delete marker.txt.

5) Next time the macro goes through the Repeat loop, the file will no longer exist, so exit from the Repeat and the macro can continue with whatever else it needs to do.  

Link to comment
Share on other sites

44 minutes ago, rberq said:

Didn't you already ask the first question in another thread?  I believe the answer was, the scheduled macro will not run again if the previous instance is still running.  I would recommend you do some testing to make sure that is true.   

For your related question, this should work:

1) When your macro starts, create a temp file -- let's call it marker.txt.

2) Start the batch script.

3) Use a Repeat loop to check over and over for the existence of marker.txt.  Do not exit from the Repeat loop as long as the file exists.  Somewhere inside the Repeat loop, include a few seconds delay -- this is just so looping won't chew up so much processor time.
 
4) As the last step in your batch script, delete marker.txt.

5) Next time the macro goes through the Repeat loop, the file will no longer exist, so exit from the Repeat and the macro can continue with whatever else it needs to do.  

Yes I already asked a similar question... Sorry. But I checked with examples. And I noticed the macro runs again every minute even if the previous instance didn't terminate... I will try your solution...

Link to comment
Share on other sites

As an 'aside'check out the Windows Task Scheduler. You can schedule MEP macros, and other things, from there. Used in combination with MEP's scheduler, one can do some things one can't do with either of them individually. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...