Cron Jobs, File Permissions, SSH & Process Management
Schedule jobs with cron, harden file permissions, connect via SSH, and manage long-running processes safely.
In plain words
Define cadence, timezone, and catch-up policy. Next, scope user, umask, key, and file modes. Finally, supervise, alert, and inspect exit logs.
Think of it like…
Cron is the alarm clock, permissions are the locked doors, SSH is the key-card tunnel, and a process supervisor is the night manager who notices a stopped worker.
Where you’ve seen it
0 3 * * * UTC flock -n /var/run/revenue.lock /opt/etl/run.sh 2>&1 | logger -t revenue; an SSH key is chmod 600 and a restricted command key uses command="..." in authorized_keys.
Words you’ll hear
- Cron
- A daemon that starts commands using five time fields plus a sparse environment; cron is not a dependency-aware orchestrator.
- Permissions
- The owner/group/other read, write, and execute bits that should follow least privilege, often 0600 for keys and 0750 for scripts.
- SSH
- Encrypted remote command and file transport authenticated with a client public key and controlled by server policy.
- Operational boundary
- A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes. Use absolute paths, UTC or an explicit
TZ, an exclusive lock such asflock -n, least-privilege modes,SSH BatchMode=yes, and a supervisor for services rather than background&.
Visual diagram
Theory & deep dive
Cron: the working mechanism
Cron supplies time-based starts, Unix modes control who can read or execute files, SSH provides authenticated remote access, and process supervision keeps jobs alive and observable.
Define cadence, timezone, and catch-up policy. Scope user, umask, key, and file modes, then lock overlapping runs and capture status; this exposes the state governed by SSH.
0 3 * * * UTC flock -n /var/run/revenue.lock /opt/etl/run.sh 2>&1 | logger -t revenue; an SSH key is chmod 600 and a restricted command key uses command="..." in authorized_keys.
Cron Jobs, File Permissions, SSH & Process Management: failure mode and production response
A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
Use absolute paths, UTC or an explicit TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &. Track Key mode as "0600 for a private SSH key", and make Lock visible to the dataset owner.
TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &.How it works, step by step
Step 1 of 41. Schedule
Define cadence, timezone, and catch-up policy. Cron supplies time-based starts, Unix modes control who can read or execute files, SSH provides authenticated remote access, and process supervision keeps jobs alive and observable.
- Key mode
- 0600 for a private SSH key
- Permissions
- The owner/group/other read, write, and execute bits that should follow least privilege, often 0600 for keys and 0750 for scripts.
When to use it & trade-offs
What it is
Cron supplies time-based starts, Unix modes control who can read or execute files, SSH provides authenticated remote access, and process supervision keeps jobs alive and observable. 0 3 * * * UTC flock -n /var/run/revenue.lock /opt/etl/run.sh 2>&1 | logger -t revenue; an SSH key is chmod 600 and a restricted command key uses command="..." in authorized_keys.
Why it matters: A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes. Use absolute paths, UTC or an explicit TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &.
When to reach for it
- Schedule jobs with cron, harden file permissions, connect via SSH, and manage long-running processes safely.
- Choose Cron because it provides this capability: A daemon that starts commands using five time fields plus a sparse environment; cron is not a dependency-aware orchestrator.
- Keep evidence for Key mode at "0600 for a private SSH key" so the last production stage-Recover - supervise, alert, and inspect exit logs-remains testable.
When to avoid or be careful
- A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
- Do not conflate Permissions with Cron. The second concept contributes different behavior: The owner/group/other read, write, and execute bits that should follow least privilege, often 0600 for keys and 0750 for scripts.
- Release only after this guardrail is in place: Use absolute paths, UTC or an explicit
TZ, an exclusive lock such asflock -n, least-privilege modes,SSH BatchMode=yes, and a supervisor for services rather than background&.
Cron / Permissions / SSH - roles, limits, and operating cost
Strengths: A daemon that starts commands using five time fields plus a sparse environment; cron is not a dependency-aware orchestrator. Cron supplies time-based starts, Unix modes control who can read or execute files, SSH provides authenticated remote access, and process supervision keeps jobs alive and observable.
Watch out: A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
Strengths: The owner/group/other read, write, and execute bits that should follow least privilege, often 0600 for keys and 0750 for scripts. In this workflow it supports: Execute - lock overlapping runs and capture status.
Watch out: The operating cost is real: one in-flight run per business interval.
Strengths: Encrypted remote command and file transport authenticated with a client public key and controlled by server policy. Its output can be checked with Exit status.
Watch out: Operating guardrail: Use absolute paths, UTC or an explicit TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Cron, and how would Key mode reveal it?”
- “Why is Permissions distinct from this behavior: encrypted remote command and file transport authenticated with a client public key and controlled by server policy?”
- Production clue: A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
- Design probe: Use absolute paths, UTC or an explicit TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &.
Benchmarks & rules of thumb
- Key mode
- 0600 for a private SSH key
- Lock
- one in-flight run per business interval
- Exit status
- cron mail or logger must retain non-zero task exits
Common mistakes & follow-ups
Common interview mistakes
- A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
- Reporting success from a job exit code without checking Key mode and Lock.
- Treating this example as complete without replay, rollback, or access boundaries:
0 3 * * * UTC flock -n /var/run/revenue.lock /opt/etl/run.sh 2>&1 | logger -t revenue; an SSH key ischmod 600and a restricted command key usescommand="..."inauthorized_keys.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A daemon that starts commands using five time fields plus a sparse environment; cron is not a dependency-aware orchestrator.
- What does the recovery plan do when this occurs? A cron job can run with a minimal PATH and different timezone, overlap yesterday's run, inherit an open secret file, or silently die after an SSH session closes.
- When is Cron insufficient for Lock, and what does adding Permissions cost in Key mode?
TZ, an exclusive lock such as flock -n, least-privilege modes, SSH BatchMode=yes, and a supervisor for services rather than background &.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Cron Jobs, File Permissions, SSH & Process Management with data engineer interview Q&A and hands-on practice.