Courseiva
hardMultiple Choice

XK0-006 Practice Question: A company runs a critical web application on a…

A company runs a critical web application on a single Linux server. The application consists of a Node.js backend and a PostgreSQL database. The server is running out of disk space frequently due to application logs. The administrator wants to implement a log rotation solution that is automated, minimizes data loss, and compresses old logs. The administrator has root access and wants to use built-in tools. Currently, logs are written to /var/log/app/access.log and /var/log/app/error.log. The application never closes its log files. Which of the following is the best course of action?

⚠ Common exam trap

Test-takers frequently assume logrotate always requires the application to close its log files (via postrotate scripts), but the copytruncate option is specifically designed for applications that keep file handles open, making it the correct choice when the application never closes its logs.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Configure logrotate with daily rotation, compression, and the copytruncate option.

Logrotate with the copytruncate option allows the log file to be rotated without requiring the application to close or reopen its file handles. This is essential since the application never closes its log files. Daily rotation with compression addresses the frequent disk space issue while minimizing data loss, and logrotate is a built-in Linux tool that runs automatically via cron.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Configure the systemd journal to capture the application logs and set MaxRetentionSec.

    Why it's wrong here

    Journald captures stdout/stderr, not files already written to /var/log/app, so access.log and error.log keep growing and disk space is not reclaimed. MaxRetentionSec only prunes journal entries. Journald suits services that log to stdout under systemd, not applications writing directly to files.

  • ✗

    Create a cron job that runs every hour to move the logs to a backup directory and restart the application.

    Why it's wrong here

    Restarting the application causes downtime and log loss, and moving files while the process holds open descriptors leaves writes going to unlinked inodes. It is tempting because cron automation is built-in, but logrotate's copytruncate handles open files without restarting the Node.js backend.

  • ✓

    Configure logrotate with daily rotation, compression, and the copytruncate option.

    Why this is correct

    The application never closes its log files, so logrotate's default rename-and-recreate leaves the process writing to the old inode. copytruncate copies the log then truncates the original in place, preserving the open file descriptor while enabling daily compression.

  • ✗

    Configure logrotate with a weekly rotation and no copytruncate, since the application will eventually close the log files.

    Why it's wrong here

    Without copytruncate, logrotate renames the file and the application keeps writing to the renamed inode, so new logs never reach a fresh access.log and disk usage is not reclaimed. Copytruncate exists precisely for daemons that never reopen their file handles; the stem explicitly states this application never closes them.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.