Cron and at jobs
Quick answer
Cron schedules recurring jobs using calendar fields; at queues a one-time job. Both run outside your interactive shell and require their respective scheduler service and authorization.
Prepare the practice environment
Run python3 lab-fixtures/logs-time/setup.py from the extracted package root as an ordinary user. Enter the printed path and check pwd. Use a fresh fixture and Bash with LC_ALL=C and set -o pipefail for each example. Never install the sample schedules, change system time or use the global logrotate configuration. Manual inspection requires an authorized disposable VM.
How it works
A user crontab has minute, hour, day of month, month, day of week, then command. System crontabs commonly add a username field. In traditional Debian cron, when both day fields are restricted, either can match; do not assume AND. Use explicit PATH, working directory, absolute paths and controlled output; percent signs in commands have special meaning. Traditional cron does not generally replay all jobs missed while powered off. at is a separate queue and depends on atd. Inspect existing schedules before editing; installing a crontab file replaces the user schedule. The fixture is a plan, not an installed job.
Read 30 2 * * 1-5 as five separate conditions: minute 30, hour 2, any month day, any month, Monday through Friday. It specifies when to request a job, not whether the job succeeds. Test the task from a private working directory and a minimal environment, then separately verify scheduler behavior in a VM. A manual run cannot establish the scheduler timezone, delivery or handling of missed jobs.
Try the examples
02:30 on weekdays in the scheduler timezone; fictional absolute path. Do not install this row.
Expected stdout:
30 2 * * 1-5 /bin/sh /home/learner/bm-report.shenv -i PATH=/usr/bin:/bin LC_ALL=C /bin/sh ./report.shA minimal environment helps expose hidden dependencies; it does not simulate cron completely.
Expected stdout:
report readyAuthorized disposable VM only; an empty user crontab can produce a nonzero result. No jobs are installed.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Never replace a real crontab with the sample. Avoid relative paths and assume neither interactive PATH nor missed-run recovery.
Practice
Write a proposed row for 06:15 every Monday, explain all five fields and run report.sh manually using the minimal environment. Do not install it.
Related references
Study: cron, crontab, at. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Cron and at jobs — Knowledge Check
Apply log, clock and scheduling concepts to private fixtures and VM-only scenarios.
Which field is first in a user crontab?
What does 30 2 * * 1-5 mean?
Which tool is for a one-time job?
What is a safe preparation before installing a cron entry?