Linux Cron Failure Troubleshooting Checklist

halfbrain_logo512adminJune 19, 2026
4 lượt xem

Linux Cron Failure Troubleshooting Checklist

Cron jobs often fail silently because their environment is different from an interactive shell. Paths, permissions, working directory, output handling and environment variables can all break scheduled tasks.

Core principle

A cron job is not just a command. It is a command running at a time, as a user, with a limited environment and usually without a visible terminal.

Checklist

  1. Identify which user owns the cron job.
  2. List the crontab.
  3. Check cron syntax.
  4. Use absolute paths for commands and files.
  5. Redirect output and errors to a log file.
  6. Check permissions of scripts.
  7. Check environment variables.
  8. Check cron logs.
  9. Run the command manually as the cron user.
  10. Document schedule and expected result.

Reusable lesson

This applies to backups, SSL renewals, imports, cache cleanup, monitoring scripts, AI automation jobs and maintenance tasks.

Checklist Type Troubleshooting
Level Intermediate
Risk Level Medium Risk
Estimated Time 30–75 minutes

When to Use This Checklist

Use this checklist when a scheduled task does not run, runs inconsistently or works manually but fails in cron.

Required Tools

SSH access, crontab, cron logs, script path, target user, log file path

Before You Start

Do not assume cron has the same environment as your terminal session. Use absolute paths and explicit logging.

Structured Checklist Steps

  1. Identify cron user.
  2. List crontab.
  3. Check syntax.
  4. Use absolute paths.
  5. Redirect output.
  6. Check script permissions.
  7. Check environment.
  8. Read cron logs.
  9. Test as cron user.
  10. Document schedule.

Rollback Plan

If a cron change creates errors or load, comment out the cron line, keep the logs and test the command manually before re-enabling.

Common Mistakes

  • No error logging.
  • Relative paths.
  • Wrong user context.
  • Missing environment variables.
  • Heavy jobs overlapping.

Related Commands

crontab -l
sudo crontab -l
which php
chmod +x /path/to/script.sh
sudo -u www-data /path/to/script.sh
grep CRON /var/log/syslog | tail -n 50
grep CRON /var/log/cron | tail -n 50

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *