How to Change Wget Logging Behavior via Signals

This article provides a quick overview of how to modify the logging behavior of a running wget process without restarting it. When executing long-running downloads in the background, you may need to redirect output to track progress or quiet down a verbose log. Linux and Unix-like systems allow you to achieve this dynamically by sending specific POSIX signals—specifically SIGUSR1 and SIGINT—directly to the active process.

Modifying Wget Logs with SIGUSR1

The most common scenario involves a wget process that is currently logging its progress directly to the terminal (stderr). If you need to log out of your session or clear up your terminal, you can send the SIGUSR1 signal to background the logging.

kill -USR1 <PID>

Note: If a file named wget-log already exists in the current working directory, wget will automatically append a suffix (e.g., wget-log.1) to avoid overwriting your previous logs.

Background Changes via SIGINT

While SIGINT (Signal Interrupt) is traditionally used to terminate a program entirely (equivalent to pressing Ctrl+C), wget handles this signal with specific nuance during active downloads.

How to Find the PID and Send Signals

To successfully alter the logging of your running wget process, follow these quick steps in your terminal:

  1. Locate the Process ID: Use pgrep or ps to find the exact PID of the download task.
pgrep -l wget
  1. Send the Signal: Use the kill command followed by the signal flag and the PID you located in the previous step.
kill -10 <PID>  # 10 is the standard numeric value for SIGUSR1 on most Linux architectures
  1. Verify the Output: Check your current directory for the creation of the new log file to ensure the signal was caught successfully.
tail -f wget-log