MidLinux

How do you schedule a recurring job, and how do you debug one that did not run?

What they are really testing: Whether you know cron and, more importantly, the classic reasons cron jobs fail silently (environment and PATH differ from your shell). That second half separates juniors from operators.

A real interview question

How do you schedule a recurring job, and how do you debug one that did not run?

What most people say

drag me

I would add it to crontab; if it does not run I would check that the cron syntax is right.

Syntax is rarely the real problem. The usual culprit, cron running with a stripped-down environment and PATH, is exactly what this question is probing, and the weak answer misses it entirely.

The follow-ups they ask next

  • The script runs fine when you run it manually but fails under cron. Why?

    Almost always environment: cron has a minimal PATH and none of your shell env. Use absolute paths, export the vars it needs, and capture stderr (2>&1) to see the actual error.

  • How would you run a periodic task in a containerized/cloud setup instead of host cron?

    A Kubernetes CronJob, or a cloud scheduler (EventBridge Scheduler/Cloud Scheduler) triggering a job/function, more observable and not tied to one host that might be down.

What the interviewer is listening for

  • Knows the 5 cron fields
  • Calls out the minimal cron env/PATH
  • Redirects output to a log (2>&1)
  • Checks cron actually fired

What sinks the answer

  • Blames only syntax
  • Unaware cron strips the environment
  • Uses relative paths
  • No output capture

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

I schedule with [crontab -e: 5 time fields + command]. The classic failure is [the minimal cron env/PATH, it does not load your profile], so I [use absolute paths, set env explicitly, redirect output 2>&1 to a log]. To debug a no-run I [confirm cron fired in syslog, then read the job log].

Keep going with linux

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free