Back to lessons

Linux Survival Basics

Show the Real User Cron Jobs

You need to inspect a user's scheduled cron commands without editing the crontab.

Command

crontab -l | sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;p'

What changed

Nothing changes. The command prints the active, non-comment crontab lines.

Danger

safe

When to use it

Use when a job ran unexpectedly or did not run and you need the user's cron schedule first.

When not to use it

Do not use it as a full system scheduler audit; cron.d, cron.daily, and systemd timers live elsewhere.

Undo or recovery

No undo needed because the command is read-only.

Expected output

Environment assignments and active cron schedule lines.

demo script

Disposable terminal steps

  1. crontab -l
  2. crontab -l | sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;p'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ crontab -l
# user crontab for demo
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5 * * * * /usr/local/bin/check-disk >> /var/log/cron-disk.log 2>&1
17 2 * * * /usr/local/bin/backup-db
0 4 * * 0 /usr/local/bin/report-weekly | /usr/bin/mail -s report ops@example.invalid
::exit-code::0
$ crontab -l | sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;p'
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5 * * * * /usr/local/bin/check-disk >> /var/log/cron-disk.log 2>&1
17 2 * * * /usr/local/bin/backup-db
0 4 * * 0 /usr/local/bin/report-weekly | /usr/bin/mail -s report ops@example.invalid
::exit-code::0

YouTube Short

See active cron lines only.

Before editing cron, strip comments and blanks. Now you can see which jobs actually exist for this user.

LinkedIn hook

Cron problems often hide behind comments, blank lines, and copied folklore.

Question: When a cron job misbehaves, do you check the user crontab or system cron first?

experiments

A/B tests to run

Metric: save_rate

A: Stop opening cron in edit mode first.

B: Show active cron jobs without touching them.