Interview Prep/Shell Scripting/Troubleshooting: cron and systemd timers

You dropped `logrotate-app.sh` into `/etc/cron.daily/` with mode 0755, but it never runs. `run-parts --test /etc/cron.daily` does not list it.

IntermediateTroubleshootingTroubleshooting: cron and systemd timers
Answer

Likely causes → On Debian and Ubuntu, run-parts only runs files whose names consist of letters, digits, underscores and hyphens. A dot (as in .sh) makes it skip the file silently. Red Hat's run-parts is more lenient, so the script "works on RHEL".

Diagnose →

run-parts --test /etc/cron.daily      # lists what would run
ls -l /etc/cron.daily/

Fix → Rename without the extension and keep the shebang: mv /etc/cron.daily/logrotate-app.sh /etc/cron.daily/logrotate-app. Confirm it is executable and owned by root.

Prevent → Avoid the cron.daily directories for application jobs; use a timer or an /etc/cron.d file with an explicit time and an absolute path.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: cron and systemd timers