avoid cron environment pitfalls around minimal PATH and unescaped percent signs when scripting crontab entries

domain: man7.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. 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'.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans