Cron time conditions - Intro and how to set them up

With our release of time conditions, we wanted to stay true to our tinkering roots and add an advanced time condition configuration through cron expressions. If you are familiar with these: this is exciting, right :star_struck:? And if you have never heard about them, don’t worry, as you can read more about them below and you’ll be using them in no time!

What’s a cron expression?

A cron expression is a string that represents a schedule when you want to execute a routine. For example in this image from crontab guru we are showing you that 5 8 * 4 6,7 means “At 08:05 on Saturday and Sunday in April.”

Click here to go to this example and have a play! https://crontab.guru/#5_8_*_4_6,7

Why are they powerful?

You are not limited by what you can setup in the UI, you can create a really customised time expression that will run your logic only at times of the day/week/month/year that you specify.

You can setup a condition that sets a schedule for your routine to only run on Saturdays in February, March and April. Or only run something the 15th of every month. You can be very specific with your cron expressions! :nerd_face: :alarm_clock:

In Apilio, you’ll be able to specify the cron expression plus a duration: this sets the length of the timeframe when you want your condition to be valid. For example, to allow a logicblock to operate every Monday at 9AM for 1 hour. This means that it will be allowed between 9AM and 10AM, on every Monday.

How do I set a time condition with a cron expression in Apilio?

These are a time condition, so head over to your condition section in Apilio:

  1. Go to https://app.apilio.com/conditions
  2. Choose new condition
  3. Choose type “time”
  4. From the dropdown, you’ll select “Advanced setup with cron”
  5. Fill in the details. You can use an external cron expression builder to write the expression. Enter a duration for your condition as well. Don’t forget to enter a name! You’ll be using this name in your logicblock to refer to this condition.
  6. Click save and you are done :slight_smile:

As is an advanced setup that is only available for our pro-plan users, and those of you who are on your trial (as you get to test everything Apilio can do for you).

Free cron expression builders

We have used crontab guru for these examples:
https://crontab.guru/

But there are many others out there:
http://www.cronmaker.com/
https://www.freeformatter.com/cron-expression-generator-quartz.html

Any further questions?

If you have any other questions, please leave them below

:bulb: Want to learn more about conditions? Have a look at these articles:

1 Like

Is there a way to use duration with the Cron expressions? So if I did a cron statement like this, to run every 5 mins betweeen 3pm and 5pm, could that be understood by apilio?

Essentially, I want to do the “between” expression from cron instead of using the duration feature you used above.

Yes you can! Select “Time frame”, and the type of time condition is “Advanced setup with cron”. This lets you enter both a cron expression and a duration :slight_smile:

I’m only confused because I still have to enter a duration with the Apilio entry, instead of just via Cron.

I want to create a condition for winter months (Oct to March). This is my cron expression for winter months, but I still have to enter 23:59 for duration on Apilio. From what you know @anna.penamartinez, is this correct? I just want this condition to be true for any winter month