Skip to content
Accueil

/

Glossaire

/

Infrastructure

/

Cron Job

Infrastructure

3 min de lecture

Qu'est-ce que Cron Job ?

A cron job is a time-based task scheduler in Unix-like systems that automatically runs scripts or commands at specified intervals, such as every hour, daily, or on specific days of the week.

What is a Cron Job?

A cron job is a scheduled task that runs automatically at predefined times or intervals on Unix-like operating systems. The name comes from the Greek word "chronos" (time) and the cron daemon, a background process that reads a schedule table called a crontab and executes commands accordingly.

Cron Expression Syntax

Cron schedules are defined using a five-field expression:

```

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ minute (0-59)

โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ hour (0-23)

โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of month (1-31)

โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ month (1-12)

โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of week (0-7, 0 and 7 = Sunday)

โ”‚ โ”‚ โ”‚ โ”‚ โ”‚

* * * * *

```

Common examples:

  • 0 9 * * 1-5 โ€” Every weekday at 9:00 AM
  • */15 * * * * โ€” Every 15 minutes
  • 0 0 1 * * โ€” First day of every month at midnight
  • 0 */6 * * * โ€” Every 6 hours
  • Cron Jobs in Automation

    Cron jobs are the backbone of scheduled automation. Common uses include:

  • Data collection โ€” Scraping prices, inventory levels, or news articles at regular intervals.
  • Report generation โ€” Compiling daily sales summaries or weekly analytics reports.
  • Database maintenance โ€” Running cleanup queries, backups, or data archival nightly.
  • File synchronization โ€” Periodically syncing files between servers or cloud storage.
  • Health checks โ€” Monitoring website uptime or API availability every few minutes.
  • Limitations of Traditional Cron

    While cron is powerful, it has significant limitations for modern automation:

  • No built-in error handling โ€” If a cron job fails, there is no automatic retry or alert unless you build it yourself.
  • No dependency management โ€” Cron cannot express "run task B after task A completes." Each job runs independently.
  • Single-server execution โ€” Traditional cron runs on one machine. If that server goes down, jobs stop silently.
  • No execution history โ€” Cron does not log whether a job succeeded or failed unless you add logging manually.
  • Timezone complexity โ€” Cron uses the server's local timezone, which can cause confusion in distributed teams.
  • Modern Alternatives

    Cloud-based schedulers like AWS EventBridge, Google Cloud Scheduler, and workflow automation platforms have largely replaced raw cron for production use. These provide retry logic, monitoring, distributed execution, and visual scheduling interfaces.

    Pourquoi c'est important

    Cron jobs are foundational to any automated workflow that needs to run on a schedule. Understanding how scheduling works helps you design reliable, repeatable automations that collect data, generate reports, or trigger processes without manual intervention.

    Comment Autonoly resout ce probleme

    Autonoly provides visual workflow scheduling that goes far beyond cron syntax. Set any schedule with a simple interface, get automatic retries on failure, view full execution history, and receive alerts when jobs fail. No server management or crontab editing required.

    En savoir plus

    Exemples

    • Scheduling a web scraping workflow to collect competitor prices every morning at 8 AM across five e-commerce sites.

    • Running a daily cron job at midnight to aggregate API data from multiple SaaS tools into a consolidated Google Sheet.

    • Setting up a weekly Monday 9 AM schedule to generate and email a PDF report summarizing the past week's data.

    Questions frequemment posees

    A cron job is the Unix/Linux implementation of a scheduled task. Windows uses Task Scheduler for the same purpose. The term 'scheduled task' is more general and platform-agnostic, while 'cron job' specifically refers to the cron daemon and crontab system on Unix-like operating systems.

    Standard cron has a minimum granularity of one minute. To run tasks more frequently, you would need to use a different scheduling mechanism, such as a loop with sleep commands, a dedicated task queue like Celery, or a real-time event-driven system.

    Common approaches include piping output to log files, using monitoring services like Cronitor or Healthchecks.io that alert when expected pings are missed, configuring email notifications via the MAILTO crontab variable, or using a workflow automation platform that provides built-in execution monitoring.

    Arretez de lire sur l'automatisation.

    Commencez a automatiser.

    Decrivez ce dont vous avez besoin en francais simple. L'agent IA d'Autonoly cree et execute l'automatisation pour vous, sans code.