Error Codes Wiki

Linux Cron Job Errors — Not Running, Permission Denied & Environment Issues

Warningsystem

Overview

Fix Linux cron job errors including jobs not running, permission denied, missing environment variables, PATH issues, and email notification failures.

Key Details

  • Cron jobs run with a minimal environment — PATH, HOME, and SHELL may differ from your interactive session
  • Default cron PATH is typically /usr/bin:/bin — commands in /usr/local/bin may not be found
  • Cron output (stdout/stderr) is emailed to the user by default if no redirect is specified
  • Crontab syntax: minute hour day month weekday command
  • System cron jobs go in /etc/crontab or /etc/cron.d/ with an extra username field

Common Causes

  • Command not found: cron PATH does not include the command's location
  • Permission denied: script not executable or user not allowed to run cron
  • Environment variables missing: cron does not source .bashrc or .profile
  • Syntax error in crontab: wrong field format or missing fields
  • Cron daemon not running (especially in containers)

Steps

  1. 1Check cron is running: systemctl status cron (or crond on RHEL)
  2. 2Use full paths in crontab: /usr/local/bin/python3 instead of just python3
  3. 3Set PATH at the top of crontab: PATH=/usr/local/bin:/usr/bin:/bin
  4. 4Redirect output to log: * * * * * /path/to/script.sh >> /var/log/myjob.log 2>&1
  5. 5Make scripts executable: chmod +x /path/to/script.sh and add #!/bin/bash shebang

Tags

linuxcronscheduled-taskenvironmenttroubleshooting

More in System

Frequently Asked Questions

Cron runs with a minimal environment. Your interactive shell has a full PATH and environment variables that cron does not. Use full paths and set env vars in the crontab.