Cron Scheduler

Cron job flow complex

The PipeGears hosted cron scheduler lets you schedule cron jobs and tasks that run automatically whenever you want them to. You can create complex jobs with multi-path execution flows by connecting blocks together visually. Flows can execute several different actions, including:

  • Sending one or more emails
  • Triggering HTTP requests
  • Sending messages to Slack
  • Writing or reading from a database
  • Publishing an MQTT message
  • or even sending a Tweet on Twitter.

Each cron job can perform complex logic and branch into multiple concurrent or conditional paths if needed. For example, PipeGears provides these basic logic modules to perform any type of string operation on the data:

  • String matching, substring extraction, or regex
  • String parsing (JSON, CSV)
  • Secure hashing (MD5, SHA)
  • Encoding and decoding (Base64, URL, HTML)
  • Math operations
  • Boolean logic
  • Date formatting

You can create multiple cron jobs, and they can each run with their own independent timezone.

Cron Scheduler

A cron scheduler defines its schedules with 5 entries, each entry representing a specific timeframe. The scheduler will execute its job when the current time matches all fields specified. Individual fields in the cron schedule represent: minute(0-59), hour(0-23), day of month(1-31), month(1-12), day of week(0-6) or (sun-sat). For example, the schedule: 45 23 * * sat will run every Saturday at 23:45
Cron scheduler explanation

A wildcard field * means that the job will run at every interval. For example, the entry 0 * * * * will run at every hour every day of the month every month and any day of the week.

Cron Scheduler Examples

  • Yearly at 9:00 on February 14th, every year: 0 9 14 2 *
  • Monthly at 14:45 on the 1st day of each month: 45 14 1 * *
  • Weekly at noon every Tuesday: 0 12 * * 2
  • Daily 10 minutes after midnight every day: 10 0 * * *
  • Hourly at five minutes past the hour: 5 * * * *
  • 3:30 every day from the 5th through 10th of each month: 30 3 5-10 * *
  • 9:00 on the 1st, 7th, 15th and 28th of each month: 0 9 1,7,15,28 * *
  • 7:30 every weekday (exclude Saturday and Sunday): 30 7 * * 1-5
  • 9:30 the first Monday of every month: 30 9 1-7 * 1

Building a Cron Job with PipeGears

PipeGears can trigger automation flows with its cron scheduler. Flows are made up of one or more functional modules that each perform a different function or action when the cron job runs. You create a flow by dragging modules onto a canvas and connecting them together visually.

Triggers are special types of modules that initiate the execution of a flow. PipeGears provides many types of triggers, including a cron trigger which runs according to its cron schedule. Each cron trigger can have its own independent timezone.

Cron jobs in PipeGears can be very simple or very complex. For example, a very basic cron job that triggers an HTTP request once per hour looks like this:

Cron job flow simple

Each module in the flow is configurable. In this example, we’ve set the cron scheduler to run every hour every day, and use the New York timezone:

Cron schedule configuration
Cron schedule configuration

Then, we set the HTTP Request to invoke a target URL and issue a GET request. The HTTP Request supports all methods (GET, POST, PUT, PATCH etc) as well as any custom HTTP header. In the case of POST, PUT or PATCH methods, you can provide the body as well. Once configured, you just press “start” and the cron job is live:

Http module configuration
Http module configuration

Common Use Cases

UNIX sysadmins have been using cron schedulers to automate tasks for years. With a hosted cron service like PipeGears, anyone can create cron jobs. Let’s look at a few use cases:

  • Send daily reminders by email, Twitter or Slack
  • Retrieve a daily digest from an external HTTP API and forward it to someone, or upload it to another API
  • Collect log files from a system via its HTTP API
  • Automatically check a website for broken links and send an alert if needed
  • Execute a health check on a remote server
  • Trigger batch jobs on remote systems
  • Measure the responsiveness of a web page and send an alert if a threshold is broken
  • Check for the presence of a specific string or message on a remote web page
  • Monitor a webpage for changes and send an email when one is detected
  • Schedule database or system updates
  • Trigger continuous integration and delivery pipelines