Site icon New Generation Enterprise Linux

Stop getting hit by PATH issues in your crontab

Cron & Task Scheduling (Cron/Systemd Timers/At)

Stop getting hit by PATH issues in your crontab

đź§© The Challenge

Ever had a script work fine in your shell but fail silently when triggered by cron? It drives me up the wall because cron doesn’t load your environment, so half your tools aren’t even found.

đź’ˇ The Fix

Explicitly set the PATH variable at the top of your crontab file to mirror your actual environment. This prevents those annoying “command not found” errors that only happen at 3 AM.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * /path/to/your/script.sh

⚙️ Why It Works

Because cron runs with a minimal, stripped-down environment, it lacks the custom paths you’ve built up over years in your shell profile. Setting it manually ensures the cron daemon actually knows where to find your binaries.

🚀 Pro-Tip: Use absolute paths for every single command inside your scripts if you want to be extra safe.

Linux Tips & Tricks | © ngelinux.com | 9/12/2026

0 0 votes
Article Rating
Exit mobile version