Why does my script work in the terminal but fail in cron?
Cron runs jobs with a minimal environment: a short PATH, no interactive shell setup, and a different working directory. Use absolute paths for commands and files, set PATH and variables explicitly in the crontab, and test with the same minimal environment.
Answered in
Cron Expressions and the Gotchas That Bite in ProductionFive fields, four special characters, and a handful of traps: the OR rule, the tiny environment, silent output, overlapping runs and time zones.
Read the full analysisOther questions this article answers
More developer tooling questions
Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the Developer Tooling beat.