Back to commands

Linux Survival Basics

Read-only

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'

Before you run this

System impact: Read-only. Low when scoped to the shown target.

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

Expected output

Environment assignments and active cron schedule lines.

System impact

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

Recovery / rollback: no state is changed.

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.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ 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.com

$ 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.com
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

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

next steps

Related commands

Linux Survival Basics Read-only

Turn Cron Into a Readable Table

Cron is easier to debug when the schedule and command stop blending together.

crontab -l | awk 'NF && $1 !~ /^#/ {printf "%-16s %s\n", $1" "$2" "$3" "$4" "$5, substr($0,index($0,$6))}'
Linux Survival Basics Can be slow

Count Source Files by Extension

A quick extension count can show whether expected content made it into the source tree.

find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Linux Survival Basics Can be slow

List URLs from a Sitemap

Before comparing sitemap coverage, print the URLs plainly.

grep -o '<loc>[^<]*</loc>' public/sitemap.xml | sed 's#<loc>##;s#</loc>##'
Linux Survival Basics Read-only

Show Context Around the First App Error

The first error often explains more than the last one.

awk '{buf[NR%5]=$0} tolower($0) ~ /(error|exception|fatal)/ {for (i=NR-4;i<=NR;i++) if (i>0) print buf[i%5]; exit}' fixtures/incidents/app.log
Linux Survival Basics Read-only

Inspect One Service Without Pager Traps

Make systemctl status safe for scripts, screenshots, and quick incident notes.

systemctl status nginx --no-pager --lines=30
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:103-gnu-unix-commands
  • lpic1:107-admin-tasks
  • lpic1:108-essential-services
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.