Creating a scheduled action

Trigger actions in your application automatically at a specified time.

Updated over a week ago

Part of automating your business is creating actions to speed up your processes and productivity. You wouldn't reach your full potential while still manually pressing each button to start them. That’s when the scheduled actions come in handy.

After reading this article you'll know how to:

  • Generate and read crontab lines

  • Set a schedule for actions

There is an infinite amount of reasons to use scheduled actions. Some of the widely used and easy-to-implement applications are:

  • Backing up data

  • Sending emails

  • Synchronizing environments

  • Mass-updating data

CRON

The logic of actions is executed through certain events called triggers. In order to trigger the processes in your application, you need to give the action command. These commands come in the form of crontab lines. Cron is a piece of software that interprets a combination of characters and converts it to an array of timestamps on which your action will be executed. The term cron is based on the name Chronos, which is the Greek personification of time. How cool is that?

Crontab lines are always formed of 5 values, separated by spaces, combined to a command: minute, hour, day of the month, month, and day of the week.

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *

The value you enter on each position affects the outcome of your crontab line.

Timezone

The CRON time is based on the UTC timezone. make sure to calculate the difference between UTC and your personal timezone in consideration if you want to schedule actions based on your timezone.

Examples

Let's take a look at this simple example:

* * * * *

An asterisk (*) is an often-used character for wildcards in computer science. It indicates every or all values are accepted. This works somewhat the same here: 5 asterisks indicate the action has to be executed every minute, every hour, every day, and every month.

Some other examples are:

  • Every 12 hours: 0 */12 * * *

  • Every first day of the month at noon: 0 12 1 * *

  • Every 15 minutes on every day from January until June: */15 * * 1-6 *

  • Every hour from 9 until 5, from Monday until Friday: 0 9-17 * * 1-5

You can make it as complex and versatile as you want, as long as it follows the cron syntax: 5 values, separated by spaces. Now you understand this syntax, you can type your own schedules. However, it's easier to use a generator that builds you a command like this one here:Crontab generator

Adding a schedule to your action

Alright, you know when you want to execute your action and create yourself a crontab. What's next? It's time to add it to the action's settings!

In this example, we're scheduling an action to send an email to a webuser every Monday at 9.

Open the action's settings and find the tab called ‘Scheduling’. Toggle the ‘Scheduled action’ on and type in or paste the cron expression that stands for your process. In our case, it’s:

0 9 * * 1

Save your action and it will be queued whenever the schedule is met.

Did this answer your question?