mydnsreport.com
    Back to Home

    Cron Expression Validator

    Cron Validator

    minute
    hour
    day
    month
    weekday
    * * * * *

    "Every minute"

    Next RunMon, Sep 28, 08:18 PM
    Quick Shortcuts
    * any, list- range/ step

    What is a Cron Job?

    A cron job is a time-based task scheduler in Unix-like operating systems including Linux. It allows you to automate repetitive tasks by scheduling commands or scripts to run at specific times, dates, or intervals. System administrators and developers use Linux cron jobs for backups, log rotation, sending scheduled emails, database maintenance, and countless other automated workflows.

    Cron Expression Format

    A cron expression consists of five fields separated by spaces: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6). Special characters include * (any value), , (value list), - (range), and / (step values).

    Common Cron Examples

    • * * * * * - Every minute
    • 0 * * * * - Every hour
    • 0 0 * * * - Every day at midnight
    • 0 0 * * 0 - Every Sunday at midnight
    • 0 0 1 * * - First day of every month
    • */5 * * * * - Every 5 minutes

    How to Use Cron on Linux

    To edit your crontab, run crontab -e in the terminal. Add your cron expression followed by the command to execute. Use crontab -l to list current jobs and crontab -r to remove all jobs. Check logs at /var/log/cron or /var/log/syslog to debug issues. System cron files live in /etc/cron.d/, /etc/cron.daily/, /etc/cron.weekly/, and /etc/cron.monthly/ for system-wide scheduled tasks.

    Cron Environment Variables

    Cron jobs run with a minimal environment — the PATH variable does not include user directories like /usr/local/bin. This is a common cause of cron failures where a command works in the terminal but not in cron. Always use absolute paths (e.g., /usr/bin/python3) or explicitly set PATH at the top of your crontab. You can also set MAILTO to an email address to receive job output and errors.

    Cron Alternatives: Systemd Timers

    On modern Linux systems, systemd timers are a powerful alternative to cron. They offer more flexibility including dependency management, catch-up on missed runs, and better logging via journalctl. Timers consist of a .timer unit file and an associated .service unit file. Run systemctl list-timers to see all active timers. For most simple use cases, cron remains the quickest and most portable solution.

    Frequently Asked Questions

    What is a cron expression?

    A cron expression is a string of five space-separated fields that define a schedule: minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–6, where 0 is Sunday). For example, 0 0 * * * runs a task every day at midnight, and */15 9-17 * * 1-5 runs every 15 minutes during business hours on weekdays.

    How do I run a cron job every 5 minutes?

    Use the expression */5 * * * *. The */5 syntax means "every 5 units" — in the minute field, this translates to every 5 minutes. Paste this expression into the validator above to confirm it parses correctly before adding it to your crontab.

    How do I view my current cron jobs on Linux?

    Run crontab -l in your terminal to list all cron jobs for the current user. To view another user's crontab (requires root), run sudo crontab -u username -l. System-wide jobs are in /etc/cron.d/ and the /etc/cron.* directories.

    Why is my cron job not running?

    Common causes: the cron service is not running (check with systemctl status cron), the script lacks execute permission (chmod +x script.sh), the PATH in cron doesn't include your command's directory, or the cron expression syntax is invalid. Check /var/log/syslog or /var/log/cron for error messages after the scheduled time passes.

    BEFORE YOU INTERPRET THE RESULT

    Validate the environment as well as the expression

    Cron syntax varies across schedulers. Confirm whether your environment uses five fields or includes seconds, how it handles day-of-month and day-of-week, and which timezone it uses. A valid expression does not mean the underlying command will succeed.

    Before relying on a production schedule, test with a harmless command and inspect your hosting logs. Account for daylight-saving changes where relevant, avoid overlapping runs, and use absolute paths when the job environment differs from your interactive shell.

    Read a DNS result → · Troubleshooting workflow →