Configuring Cron Jobs

Configuring Cron Jobs

— Last updated on

Following up our previous article about using the available Easy!Appointments console commands, today we will take a closer look on how to schedule some of them to automatically run based on a predefined schedule.

Cron Jobs (or Scheduled Tasks on Windows) are time-based scheduled jobs that are executed on predefined intervals or specific time during a day. Typically they automate maintenance and administration tasks although they can be used in many different ways.

The most common use cases for an Easy!Appointments installation are the automation of the Google Calendar Synchronization feature and the automated database backups.

Configuring On Linux/Mac

In order to use Cron Jobs on a Linux/Mac environment, you will need to open the crontab utility from the terminal.

crontab -e

This will open the predefined editor that you can use to add cron based commands. Each line represents a different scheduled task and you can add as many as you need. For Backup and Google Calendar Sync jobs that run every hour, we will need to add the following commands.

0 * * * * /usr/bin/php /path/to/easyappointments/index.php console backup
0 * * * * /usr/bin/php /path/to/easyappointments/index.php console sync

The first “0 * * * *” part configures the command to run every hour (0 minutes * hours * days etc). The second part is the command that will be executed (make sure you change the path to the index.php file with your own).

There are user friendly tools online that can generate the crontab line for you:

Configuring On Windows

Windows have a slightly different way to define scheduled tasks than Unix-like systems.

Open The Task Scheduler

Create A New Task

There are plenty of online tutorials about how to configure scheduled tasks on Windows in case you need additional information. You can get started with this Medium post about configuring a PHP Cron in Windows.

Premium Services

Rather not run it yourself?

Managed Hosting runs Easy!Appointments on our servers or manages it on yours, with updates, backups and a reply from the core team within one business day. White label, support sessions and custom work are in the services.

Get Managed Hosting