Fix Cron Jobs Not Running in Linux
Identify common reasons cron jobs fail to execute, including environment variables, paths, and permissions.
Confirmed working on: All Linux Distributions
Before you begin
Problem overview
You scheduled a task in your crontab, but it fails to execute at the designated time, or it runs but fails silently without producing the expected results.
Common causes
- The cron daemon is not running on your system.
- The script uses commands that are not in cron’s limited
PATH. - The script file lacks executable permissions.
Solution 1: Use absolute paths in the crontab
Cron does not know where commands like python3, node, or even basic utilities are located unless you specify the exact path.
- Open a terminal.
- Find the absolute path of the command you are trying to run:
(This might outputwhich python3/usr/bin/python3) - Edit your crontab:
crontab -e - Update the job to use absolute paths for both the executable and your script:
* * * * * /usr/bin/python3 /home/user/scripts/backup.py - Save and exit the editor.
You can also define the PATH variable directly at the top of your crontab file to avoid writing full paths for every command.
Solution 2: Make the script executable
If you are running a bash script, it must have execute permissions.
- Open your terminal.
- Grant execute permissions to your script:
chmod +x /home/user/scripts/backup.sh - Test the script manually to ensure it runs correctly before relying on cron.
Solution 3: Capture cron output for debugging
By default, cron emails errors to the system administrator account. If you do not have a local mail server configured, you lose these error messages.
- Edit your crontab:
crontab -e - Redirect both standard output and error output to a log file:
0 2 * * * /home/user/scripts/backup.sh >> /tmp/cron_backup.log 2>&1 - Wait for the job to run, then inspect the log file:
cat /tmp/cron_backup.log
Solution 4: Verify the cron daemon status
If no cron jobs are running at all, the service might be stopped.
- Check the status of the cron daemon:
(On some distributions like Fedora or Arch, the service is namedsudo systemctl status croncrond.) - If it is stopped, start the service:
sudo systemctl start cron - Enable it to run on boot:
sudo systemctl enable cron
Confirm the result
- Repeat the exact action that originally triggered the problem.
- Confirm the original error or symptom is gone and no new warning has appeared.
- If the guide changed a driver, service, package, or system setting, restart once and test again.
- If the result is worse or unexpected, stop. Reverse only the last change using its documented restore option; if none is documented, use your backup or qualified support.
Questions about this fix
Why does my script work in the terminal but not in cron?
Cron runs in a minimal environment. It does not load your shell profile, so it often lacks the PATH variables needed to find your commands.
How do I see if a cron job actually ran?
You can check the system logs in /var/log/syslog or /var/log/cron, or you can redirect the output of the job to a specific file.
Did this fix work for you?
Weighted Consensus Protocol
Did this solution resolve your issue?
Confirming if this works strengthens verification statistics on the registry.
FixingTeam10,000 rep
Official Project Maintainers
The core engineering and moderation team behind FixingBook. We curate, verify, and maintain the standards of the troubleshooting ledger.
Discussion (0)
No comments yet. Share your experience or verify if this fixed your issue!
