· about 35 minutes · runs on ubuntu-26.04-devops · unrated
An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.
The application keeps one directory per release in /srv/app/releases/, named after the moment it
was built — 20260913-101500, sometimes with a label after a space, such as
20260911-180000 hotfix. current in the same directory is a symlink to the release in use.
prune-releases is supposed to keep the five newest releases and delete the rest, every night. This
week it:
20260830-090000 rollback behind, and complained about files called rollback that do not
exist;It has not run at all since the last reboot.
What is expected, and graded — the grader runs prune-releases itself, against its own directories,
through the RELEASES_DIR variable the script already reads:
current and anything that is not a release directory are left alone.RELEASES_DIR does not exist, the script exits non-zero and deletes nothing, wherever it was
started from.You have root through sudo.
The machine is checked, rebooted, and checked again. A check passes only if it passes both times.
| Check | Objective |
|---|---|
| 01_keeps_the_five_newest | Select files by the data in their names, not by incidental metadata |
| 02_names_with_spaces | Handle every file name safely, spaces included, and never act in the wrong directory |
| 03_missing_directory_deletes_nothing | Handle every file name safely, spaces included, and never act in the wrong directory |
| 04_runs_every_night | Schedule a maintenance script with a systemd timer that survives reboots |
Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).
man 1 lsman 1 sortman 1 xargsman 5 systemd.timer4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:
What does this print?
cd "$(mktemp -d)"
mkdir "a b" b
echo "a b" | xargs printf '[%s]'; echo
[a][b]
xargs splits its input at blanks, so one name becomes two arguments. Had the command been rm -rf, it would have deleted the unrelated directory b and left "a b" alone. NUL-separated input (xargs -0) or a glob keeps each name whole.
man 1 xargs · executed in a sandbox
What does this print?
cd "$(mktemp -d)"
mkdir 20260102-0900 20260101-0900 "20260103-0900 hotfix"
for d in [0-9]*; do printf '%s|' "$d"; done; echo
20260101-0900|20260102-0900|20260103-0900 hotfix|
Pathname expansion returns matches sorted by name, and each match is one word however many spaces it contains. Timestamped names that start with year, month and day therefore come back in chronological order, regardless of creation order or mtime.
man 1 bash (Pathname Expansion) · executed in a sandbox
What does this print?
cd "$(mktemp -d)"
mkdir real && ln -s real link
[ -d link ] && echo dir; [ -L link ] && echo link
dir link
test -d follows symlinks, so a link to a directory is a directory to it; -L is the only test that looks at the link itself. A cleanup that must not remove the current link has to exclude it with ! -L. The two lines are joined by a space in the answer.
man 1 test · executed in a sandbox