Your DevOps study space

Real explanations. Videos with tests. Fresh exams every time. Keep the streak alive and watch the XP stack up.

Scheduling jobs & reading logs · Linux Docs · StackwisePlanDevOps Scheduling jobs & reading logs · Linux Docs · StackwiseCodePython Scheduling jobs & reading logs · Linux Docs · StackwiseBuildDocker Scheduling jobs & reading logs · Linux Docs · StackwiseTestDevOps Scheduling jobs & reading logs · Linux Docs · StackwiseReleaseGit Scheduling jobs & reading logs · Linux Docs · StackwiseDeployKubernetes Scheduling jobs & reading logs · Linux Docs · StackwiseOperateLinux Scheduling jobs & reading logs · Linux Docs · StackwiseMonitorDevOps

Pick a topic

Eight tracks, each with docs, a cheat sheet, videos and tests.

How it works

One loop, repeated until it sticks.

Jump back in

Picked up from where you left off.

Free forever

Your DevOps journey starts with one click.

Sign in with Google or GitHub to open every chapter, video, test and challenge. Your progress is saved wherever you learn.

Scheduling jobs & reading logs

A server does a lot of work when nobody is logged in: backups at night, cleanup every hour, health checks every few minutes. You schedule that work with cron or systemd timers, and you find out whether it worked by reading logs.

The crontab format

Each user has a crontab, a list of jobs. Every line is five time fields followed by the command to run:

30minute0-592hour0-23*day ofmonth*month1-121-5day ofweek/opt/backup.shthe command= at 02:30, Monday to Friday* every value 1,15 a list 1-5 a range */10 every 10th
Five time fields, then the command. Read them left to right as "minute, hour, day, month, weekday".
FieldAllowed values
minute0–59
hour0–23
day of month1–31
month1–12 (or jan–dec)
day of week0–7, where 0 and 7 are both Sunday (or sun–sat)

In each field * means every value, 1,15 is a list, 1-5 a range and */10 a step ("every 10th").

*/5 * * * *    every 5 minutes
0 * * * *      at the start of every hour
30 2 * * *     every day at 02:30
0 9 * * 1-5    09:00 Monday to Friday
0 0 1 * *      midnight on the 1st of every month
0 */6 * * *    every 6 hours (00:00, 06:00, 12:00, 18:00)
@reboot        once, when cron starts after a boot
@daily         same as 0 0 * * *   (also @hourly, @weekly, @monthly)

Times are in the server's time zone (check with timedatectl), which on cloud servers is often UTC. One oddity: if you restrict both day of month and day of week, the job runs when either matches, so 0 0 13 * 5 means every 13th and also every Friday.

Editing crontabs

$ crontab -e          # edit your jobs (opens an editor, installs on save)
$ crontab -l          # list your jobs
$ sudo crontab -u deploy -l   # another user's jobs
$ crontab -r          # DELETES your whole crontab without asking. Careful: -r is next to -e

There are also system-wide places: /etc/crontab and files in /etc/cron.d/ have an extra field for the user to run as (0 3 * * * root /usr/local/bin/backup). Scripts dropped into /etc/cron.daily/, cron.hourly, cron.weekly or cron.monthly run on that schedule with no time fields at all, but on Debian and Ubuntu their file names may only contain letters, digits, - and _: a file called backup.sh there is silently skipped.

Cron's environment: why jobs work in the terminal but not in cron

Cron does not load your ~/.bashrc or ~/.profile. Jobs run with a tiny environment:

  • PATH is only /usr/bin:/bin, so anything in /usr/local/bin, ~/.local/bin or a virtual environment is "not found". Use full paths, or set PATH=... on a line at the top of the crontab.
  • The shell is /bin/sh (dash on Ubuntu), not bash. Put bash syntax in a script with a bash shebang and call the script.
  • Your exported variables (API keys and so on) don't exist. Set them in the crontab, or have the script load them from a file.
  • The working directory is your home folder, so relative paths in the script point there. Use absolute paths or cd first.
  • % is special in a crontab line (it means "newline"). date +%F must be written date +\%F.

Output of a job is emailed to you, but only if the server has a mail program; on a typical Ubuntu server it isn't installed and the output is thrown away. Always redirect it to a log file so you can see what happened:

PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=""

# every 5 minutes, keep both output and errors
*/5 * * * * /home/demee/bin/healthcheck.sh https://demee.cc >> /home/demee/logs/health.log 2>&1

# nightly backup; flock -n skips this run if the previous one is still going
0 3 * * * flock -n /tmp/backup.lock /home/demee/bin/backup.sh /srv/app >> /home/demee/logs/backup.log 2>&1

To check whether cron ran a job at all, look for its CMD lines: journalctl -u cron --since today or grep CRON /var/log/syslog.

systemd timers, briefly

A timer is systemd's alternative to cron. You write two small unit files: a .service that says what to run and a .timer that says when.

# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup

[Service]
Type=oneshot
User=demee
ExecStart=/home/demee/bin/backup.sh /srv/app

# /etc/systemd/system/backup.timer
[Unit]
Description=Run backup every night

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target

$ sudo systemctl daemon-reload
$ sudo systemctl enable --now backup.timer
$ systemctl list-timers                    # all timers, with next and last run
$ systemd-analyze calendar "Mon..Fri *-*-* 09:00"   # check an OnCalendar expression

Compared with cron, the output lands in the journal automatically (journalctl -u backup), Persistent=true runs a missed job after the machine was off, and systemctl start backup.service runs it on demand for testing. Ubuntu itself uses timers for jobs like log rotation.

Reading logs with journalctl

systemd collects the output of every service, plus kernel and system messages, in the journal. journalctl reads it; newest entries are at the bottom.

$ journalctl -u nginx                  # one service (-u = unit)
$ journalctl -u nginx -n 50            # just the last 50 lines
$ journalctl -u nginx -f               # follow live, like tail -f
$ journalctl -u nginx --since "1 hour ago"
$ journalctl --since "2026-09-27 09:00" --until "2026-09-27 10:00"
$ journalctl -p err -b                 # errors and worse, since this boot
$ journalctl -u myapp -g "timeout"     # only lines matching a pattern
$ journalctl -k                        # kernel messages (disks, out-of-memory kills)
$ journalctl --disk-usage              # how much space the journal uses
$ sudo journalctl --vacuum-time=14d    # delete journal data older than 14 days

Priorities from most to least severe: emerg (0), alert, crit, err, warning, notice, info, debug (7). -p warning shows warning and everything more severe. If you only see your own messages, use sudo or join the adm or systemd-journal group.

Classic log files in /var/log

FileWhat's in it
/var/log/sysloggeneral system messages (Debian/Ubuntu; /var/log/messages on Red Hat family)
/var/log/auth.loglogins, SSH, sudo use (/var/log/secure on Red Hat family)
/var/log/kern.logkernel messages
/var/log/apt/history.log, dpkg.logwhat was installed or upgraded, and when
/var/log/nginx/access.log, error.logeach web request, and web server errors
$ sudo tail -f /var/log/auth.log                  # watch logins live
$ sudo grep "Failed password" /var/log/auth.log | tail
$ ls /var/log/syslog*
/var/log/syslog  /var/log/syslog.1  /var/log/syslog.2.gz  ...
$ zgrep -i "error" /var/log/syslog.2.gz           # grep inside a compressed old log
$ zless /var/log/syslog.2.gz

logrotate: stopping logs from filling the disk

Those .1 and .gz files come from logrotate, which runs once a day (on Ubuntu via logrotate.timer). It renames the current log, starts a fresh one, compresses old ones and deletes the oldest. Packages put their rules in /etc/logrotate.d/; add one for your own app:

# /etc/logrotate.d/myapp
/var/log/myapp/*.log {
    daily
    rotate 14
    compress
    delaycompress
    missingok
    notifempty
    copytruncate
}

$ sudo logrotate -d /etc/logrotate.d/myapp   # dry run: show what would happen
$ sudo logrotate -f /etc/logrotate.d/myapp   # force a rotation now to test
  • daily: rotate every day (or weekly, monthly, size 100M).
  • rotate 14: keep 14 old files and delete anything older.
  • compress gzips old files; delaycompress leaves the newest old one (.1) uncompressed for one more round.
  • missingok: no error if the log doesn't exist; notifempty: don't rotate an empty file.
  • copytruncate: copy the log, then empty the original, for apps that keep the file open.

Comments in logrotate files must be on their own line: rotate 14 # keep two weeks is an error ("bad rotation count"). copytruncate is the simple choice when the app can't be told to reopen its log file; a few lines written during the copy can be lost. The alternative is create plus a postrotate script that tells the app to reopen its log. If logrotate complains that a directory has "insecure permissions", add a line like su myapp myapp to the rule so it knows which user to rotate as.

Questions

Pick an answer. Get it wrong and you can try again right away, no waiting. 10 questions per topic - pick a filter below, then use Recreate questions for a fresh set on that topic.

Fresh questions every time

Exam

A mixed test across the whole site, shuffled so you never know which topic comes next. When you submit, every mistake comes with the reason and a jump to the exact moment in the video that explains it.

30 questions 6 topics 20 minute limit Up to 70 XP
1–4 answer · ←→ move
History

Essay

0 / 200-250 words
Sample answer
History
0:00 / 0:00
Not started

on YouTube
Subscribe

Topic progress

Activity

Achievements

Settings

Your profile and your account.

Profile details

* Required. Saved in this browser until you sign in.

Letters, numbers, dots, dashes and underscores.
0 / 160

Account

Checking…

App

Install Stackwise on your phone or computer. It opens in its own window from your home screen, and the Docs and cheat sheets you've opened keep working without internet.

Only admins can see this

Dashboard

Sign-ups, activity, messages and reviews in one place.

Prove it

Certificates

Pass a topic's test and get a certificate with its own public page you can share or add to LinkedIn. Each test is 10 questions drawn at random and graded on the server; you need 8 right, you have 15 minutes, and you get one try per topic a day.

From first command to production

Linux for DevOps

A path through Linux the way DevOps engineers use it: ten stages, every command explained with its flags, examples, real output and mistakes, the combinations engineers chain together, and incidents worked through step by step. Practise everything in a safe lab folder.

Before the interview

Interview prep

Questions that come up in real DevOps interviews, with the kind of answer that lands. Say yours out loud first, then compare. Each one links to the chapter that goes deeper.

    Private to you

    My notes

    Everything you wrote down while watching and reading, in one place. Saved to your account, never shown to anyone.