Part of automating your business is creating actions to speed up your process and productivity. You wouldn't reach full potential if you still have to manually press on each button to start them.
After reading this article you'll know:
- How to generate and read crontab lines
- How to set a schedule for actions
There are an infinite amount of reasons why to use scheduled actions. Some of the most used and easy to implement applications are:
- Backing up data
- Sending emails
- Synchronizing environments
- Mass-updating data
To trigger these processes on a scheduled moment, you'll need to give the action a 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 in the outcome of you crontab line.
Let's take a look at the most 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, 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 everyday 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 which builds you a command: Crontab Generator
Adding a schedule to your action
Alright, you know when you want to execute your action and got yourself a crontab. Now what? Time to add it in the action's setting!
Open the action's settings and look for Triggers. By default, an action is set to Manual, so you can start it, you guessed it, manually. We'll set our action to Scheduled.
Right after clicking, a new input field appears. This is where the crontab line is entered.
In this example, we're scheduling an action to send an overview of activities of last week, every Monday at 9. Save your action and the action will be queued whenever the schedule is met.
Note: Adding a schedule to an action in an application's sandbox will not result in an automated action. Only production environments trigger scheduled actions. Merge the schedule added in the sandbox to your production environment to see it in effect.
In the action overview you'll find a column which displays the action's schedule.
The crontab is converted to a more readable value, our example resulting in
at minute 0, on hour 9, every day, on Mon.