Don't run profile if specific other profile(s) are running?

English Support for Syncovery on Windows.
Post Reply
james_c_stein@fd.org
Posts: 14
Joined: Wed Oct 28, 2020 1:01 pm

Don't run profile if specific other profile(s) are running?

Post by james_c_stein@fd.org »

Is there a way to set a profile to not run if another profile is running?

I know I can chain profiles so one runs after the other. However, occasionally I run into a situation where the chained profile takes longer than the repeat period on the profile it is chained to. I'd like to be able to either stop the origin profile from running if the chained profile is still running, or stop to the chained profile so the origin profile can run. Are either of these options possible?

tobias
Posts: 482
Joined: Tue Mar 31, 2020 7:37 pm

Re: Don't run profile if specific other profile(s) are running?

Post by tobias »

Hello,
please see the OnCanRunProfile Sample Script on our PascalScript page:
https://www.syncovery.com/pascalscript/

james_c_stein@fd.org
Posts: 14
Joined: Wed Oct 28, 2020 1:01 pm

Re: Don't run profile if specific other profile(s) are running?

Post by james_c_stein@fd.org »

Thanks that looks like it will do the trick.

james_c_stein@fd.org
Posts: 14
Joined: Wed Oct 28, 2020 1:01 pm

Re: Don't run profile if specific other profile(s) are running?

Post by james_c_stein@fd.org »

One question,

Does the example script just pause the profile for 60 seconds and then run it regardless of P1 or P2 already running or does it check again in 60 seconds?

I ask because it doesn't actually seem to be stopping the 2 profiles from running together.

I already have p2 chained to run after P1. The problem is P1 starts up again before p2 is finished.

tobias
Posts: 482
Joined: Tue Mar 31, 2020 7:37 pm

Re: Don't run profile if specific other profile(s) are running?

Post by tobias »

Hi,
the check is done every time before the profile is launched.

Did you enter the PascalScript via the global Program Settings, tab sheet Advanced, using the "Global Pascal Script" checkbox?

james_c_stein@fd.org
Posts: 14
Joined: Wed Oct 28, 2020 1:01 pm

Re: Don't run profile if specific other profile(s) are running?

Post by james_c_stein@fd.org »

Yes I did. I restarted the machine and since then haven't seen those 2 profiles running together. I now need to modify that script for other profiles I have several pairs of profiles that I don't want running at the same time.

tobias
Posts: 482
Joined: Tue Mar 31, 2020 7:37 pm

Re: Don't run profile if specific other profile(s) are running?

Post by tobias »

Hi,
great, you can extend the mutual exclusions, for example:

Code: Select all

const p1='Profile Name 1';
         p2='Profile Name 2';
         p3='Profile Name 3';
         p4='Profile Name 4';

function OnCanRunProfile(const ProfileName:UnicodeString; var PostponeBySeconds:Integer):Boolean;
begin
  if ProfileName=p1 then
     Result:=not ProfileRunning(p2)
  else
     if ProfileName=p2 then
       Result:=not ProfileRunning(p1)
     else
     if ProfileName=p3 then
       Result:=not ProfileRunning(p4)
     else
     if ProfileName=p4 then
       Result:=not ProfileRunning(p3)
     else
       Result:=true;
  if not Result then
     PostponeBySeconds:=60;
  end;

james_c_stein@fd.org
Posts: 14
Joined: Wed Oct 28, 2020 1:01 pm

Re: Don't run profile if specific other profile(s) are running?

Post by james_c_stein@fd.org »

I never said thanks for this.. I wound up with several pairs of profiles i didn't want running at the same time and the if else became unmanageable so I came up with this. I figured I'd share it.

Code: Select all

const p1='Profile Name 1';
      p2='Profile Name 2';

      p3='Profile Name 3';
      p4='Profile Name 4';

      p5='Profile Name 5';
      p6='Profile Name 6';

      p7='Profile Name 7';
      p8='Profile Name 8';

      p9='Profile Name 9';
      p10='Profile Name 10';

function OnCanRunProfile(const ProfileName:UnicodeString; var PostponeBySeconds:Integer):Boolean;
begin
  Result:=false;
  case (ProfileName) of
    p1: Result:=not ProfileRunning(p2);
    p2: Result:=not ProfileRunning(p1);
    p3: Result:=not ProfileRunning(p4);
    p4: Result:=not ProfileRunning(p3);
    p5: Result:=not ProfileRunning(p6);
    p6: Result:=not ProfileRunning(p5);
    p7: Result:=not ProfileRunning(p8);
    p8: Result:=not ProfileRunning(p7);
    p9: Result:=not ProfileRunning(p10);
    p10: Result:=not ProfileRunning(p9);
  else
    Result:=true;
  end;

  if not Result then
    PostponeBySeconds:=60;
end;

tobias
Posts: 482
Joined: Tue Mar 31, 2020 7:37 pm

Re: Don't run profile if specific other profile(s) are running?

Post by tobias »

Thanks!

Post Reply