Interview Prep/Linux/Networking, SSH & Scheduling

Why does a script work manually but fail in cron?

IntermediateConceptNetworking, SSH & Scheduling
Answer

Cron runs with a minimal environment: PATH=/usr/bin:/bin, SHELL=/bin/sh, no profile or bashrc, a different working directory, no TTY. Fixes: use absolute paths, set PATH= and SHELL=/bin/bash at the top of the crontab, cd explicitly, and capture output to a log. Also, % must be escaped as \% in crontab lines (common with date +%F). Check grep CRON /var/log/syslog or journalctl -u cron.

All Linux questions Roadmap: Linux

More on Networking, SSH & Scheduling