Plainnotes

Cron runs your script with a different environment

2026-08-22 · 2 min readTools

A script works in the terminal and fails in crontab with command not found, or with a Python import error.

Cron's environment is minimal: PATH is usually just /usr/bin:/bin, the shell is /bin/sh, no profile is read, and there is no LANG.

Three fixes, best first. Use absolute paths inside the script. Or declare at the top of the crontab:

PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash
LANG=en_US.UTF-8

Or wrap the invocation in bash -lc, accepting that login scripts bring their own side effects.

For debugging, put env > /tmp/cron-env.txt at the top of the script and diff it against your interactive shell.