Linux Labs

Packages, services, and logs / Stage 12 of 13 · step 7 of 9

Set up log rotation

medium ~20 min
Not running Starting usually ~20 s
Report a problem

Situation

The myapp service appends a line to /var/log/myapp/app.log every two seconds. The log has no rotation: the file is already large and keeps growing. It needs proper rotation with logrotate.

Task

  1. A rule sits in its own file, /etc/logrotate.d/myapp, covers /var/log/myapp/app.log and parses in logrotate without errors.
  2. Under this rule the log rotates daily, seven old files are kept, and old files are compressed.
  3. One rotation has already run: the log's old contents sit in an archive next to it.
  4. After the rotation the myapp service keeps writing to /var/log/myapp/app.log.
  5. Later rotations by this rule do not take the service's writes away from app.log either.

Constraints

  • Do not change the myapp service or its program, /usr/local/bin/myapp.
  • Do not delete the log's old contents.

The tools you need are already installed. There's no internet on this machine.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 5
  • The /etc/logrotate.d/myapp rule covers /var/log/myapp/app.log and parses without errors — not checked yet
  • Under the rule the log rotates daily, seven old files are kept and old files are compressed — not checked yet
  • Rotation has run — the log's old contents sit in an archive — not checked yet
  • After rotation the myapp service writes to /var/log/myapp/app.log — not checked yet
  • Later rotations by the rule do not take the service's writes away from app.log either — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…