Scripts Failing When Run via crontab -e

- Pranav Sivvam
Mar 28, 2025

When scripts work perfectly when run manually but fail mysteriously when executed via cron.

root cause

This happens because of the minimal environment that cron has - it runs with very limited PATH, environment variables, and shell context compared to your interactive shell.

solution

Reference: https://stackoverflow.com/questions/20582224/shell-script-not-running-via-crontab-but-runs-fine-manually

The fix: Manually add it to /etc/crontab with the full path specification:

*/10 *     * * *   ghost  /bin/bash /home/scripts/run.sh

This approach:

Additional troubleshooting: