LinuxsystemdcronjournaldIntermediate~4h

Linux: Processes & Systems

Know what the machine decided

A running machine is making decisions without you: what to schedule, what to restart, what to write down, and what to kill when it runs out of memory. This is how to find out which of those it made and why — and how to put a service of your own under the same supervision, on a machine you are willing to break.

Modules
6
Drills
0
Build steps
11
Time
~4h

Walk out able to

Take a machine you did not set up, find out why a service stopped coming back, and put one of your own under supervision that survives its own failures.

What you work on

01

Processes and their states

Read a listing; name the one no signal can end.

02

Signals and the two that win

Ask a process to stop; know what insisting costs.

03

Units that come back

Restart policies, ordering, and why it did not.

04

Schedules, logs and limits

cron fields, journal filters, and the refusal itself.

The pitch

What you practise, and what you leave with

Two services of your own, wired so one cannot run before the other, and the number a narrow journal query returns from them.

You will practise

  • Process states, signals and signal targets
  • Restart policies, and dependency versus order
  • Crontab fields, and why a job did nothing
  • Journal filters, limits and the memory killer

Afterwards you can

  • Read a process listing and name every state
  • Stop a process without losing its cleanup
  • Say why a unit did not come back after a boot
  • Get an answer out of a journal in one command

Modules

6 modules, 23 items

Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.

  1. 1

    Where a process comes from

    ~42 min

    Get a Linux you can break, read its process table, and account for every row.

    • LessonWhat the machine decides without you4 min
    • Build stepGet a Linux you can break10 min
    • LessonRead a process table line by line13 min
    • LessonAccount for where a process came from15 min
  2. 2

    Ask it to stop, then insist

    ~41 min

    Send the right signal to the right thing, and know what the uncatchable one costs.

    • LessonSay what each signal does to a process15 min
    • LessonAim a signal at exactly one thing12 min
    • Build stepKill something that refuses to stop14 min
  3. 3

    Make it come back

    ~45 min

    Write a unit, choose a restart policy, and say why the order it started in was wrong.

    • LessonRead a unit file as a promise14 min
    • LessonTell a dependency from an order13 min
    • Build stepWrite a program that fails on purpose6 min
    • Build stepPut it under a restart policy7 min
    • Build stepCount what the manager actually did5 min
  4. 4

    Work that happens without you

    ~25 min

    Read a crontab line for when it fires, and know why it did nothing when it did.

    • LessonRead a crontab line for when it fires13 min
    • LessonExplain a job that ran and did nothing12 min
  5. 5

    Find out what it said

    ~28 min

    Ask the journal a narrow question, and get the direction of its filters right.

    • LessonAsk the journal a narrow question14 min
    • Build stepProve which way the filter points8 min
    • Build stepFind a real failure on your machine6 min
  6. 6

    What the system will not give

    ~51 min

    Recognise a refusal by the failure it produces, and predict who the kernel kills.

    • LessonName the failure a limit produces14 min
    • LessonPredict who the kernel kills first13 min
    • Build stepStage the log the services will read4 min
    • Build stepMake a producer run without you7 min
    • Build stepClassify every line into the journal8 min
    • Build stepAsk it the one question5 min

A taste of the code

it starts by hand, and fails on every boot
[Unit]
Description=Relay the feed
Requires=feed.service

$ systemctl status relay.service

● relay.service - Relay the feed
     Active: failed (Result: exit-code)
   Main PID: 4471 (code=exited, status=1/FAILURE)

relay[4471]: cannot open /var/lib/feed/latest: No such file or directory

Stop guessing why it did not come back.

The first item is free. ~4h of focused work, at your own pace.

Intermediate~4h6 modules