There are many ways to tackle this programmatically [and have its own Pros and Cons]
If your requirement is to Run your automation from 8am to 10pm every hour; daily.
Create a secondary automation as below.
- Scheduled to run daily at 8am.
- Add 14 Script activity with below code with 13 wait activities [of 1 hours] (change this frequency) as per your requirement.
SSJS code to run automation
<script runat="server">
Platform.Load('core', '1');
var myAutomation1 = "YourAutomationKey"; //External key of the automation
var prog1 = Program.Init(myAutomation1);
prog1.Perform();
</script>
WSproxy code to run automation [updated as per suggestion by Greg]
/* You will be able to access automations in child BU from the parent BU and the reverse, from child to parent,
but don't think you won't be able to go from child BU to child BU. */
<script runat="server">
Platform.Load("core","1.1.1");
var prox = new Script.Util.WSProxy();
//Switch context to different BU. Change the MID to suit.
prox.setClientId({ "ID": xxxxxxxx });
// Need to retrieve the ObjectID for the Automation, which isn't available via the SFMC interface.
var cols = ["Name", "ProgramID", "IsActive"];
var filter = {
Property: "Name",
SimpleOperator: "equals",
Value: "xxxxxxxxxx Name of your Automation xxxxxxxxxxxx"
};
var desc = prox.retrieve("Automation", cols, filter);
// Output ObjectID if you want to see it.
Write('<br>ObjectID: ' + desc.Results[0].ObjectID);
var props = {
ObjectID: desc.Results[0].ObjectID
};
var action = "start";
var opts = {};
var res = prox.performItem("Automation", props, action, opts);
var status = res.Status;
var statusCode = res.Results[0].StatusCode;
Write("status code: " + statusCode);
//reset the context if required
prox.resetClientIds();
</script>