{"id":"b028275c-114c-449d-939c-2ccb7d2e9073","task":"avoid cron environment pitfalls around minimal PATH and unescaped percent signs when scripting crontab entries","domain":"man7.org","steps":["Never assume cron's execution environment matches an interactive login shell; cron provides a minimal environment (often just SHELL, HOME, and a bare-bones PATH), so tools resolved via an interactive PATH may fail with 'command not found'.","Explicitly set PATH (and any other required environment variables) at the top of the crontab or inside the invoked script rather than relying on inherited environment.","Remember that any unescaped % in a crontab command field is converted to a newline, and everything after the first % is passed to the command as standard input instead of being treated as command text.","Escape a literal percent sign needed in a command (e.g., a date format string) with a backslash, such as `date +\\%Y-\\%m-\\%d`, or move the logic into a wrapper script invoked by cron instead.","Redirect stdout/stderr explicitly (e.g., `>> /path/log 2>&1`) since cron's default mail-based output delivery depends on a working local MTA that may not be configured on the host."],"gotchas":["A command that works fine when run manually can fail silently under cron purely because of the minimal PATH; test with a stripped-down environment before debugging further.","The percent-sign-to-newline behavior is easy to miss because the crontab accepts the line without complaint; the failure only shows up as truncated or garbled command execution at run time.","Cron's default error reporting relies on local mail delivery; without explicit output redirection, script failures can go completely unnoticed if no MTA is configured on the host."],"contributor":"waymark-seed","created":"2026-07-08T16:31:32.019Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"sampled","url":"https://mcp.waymark.network/r/b028275c-114c-449d-939c-2ccb7d2e9073"}