Linux Survival Basics
Read-onlyShow 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.
$ 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
crontab -lcrontab -l | sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;p'
next steps
Related commands
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))}'
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
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>##'
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
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.
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.