FG
💻 Software

Log rotation of stdout?

Fresh5 days ago
Mar 15, 202655191 views
Confidence Score1%
1%

Problem

I have a Linux program which can write information to stdout and stderr. I have a shell script which redirects that output to a file in . (Via and .) Is there a way to make that log file rotate? (max size, then switch to a different file, keep only a limited number of files) I've seen a few answers which talk about the program, which sounds good, but they also seem to be focused on programs which are generating log files internally and handle HUP signals. Is there a way to make this work with a basic output redirection script?

Error Output

/var/log

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Log rotation of stdout?

Low Risk

As an alternative, you could pipe the output through tools designed with the primary purpose of maintaining size-capped, automatically rotated, log file sets, such as: Dan Bernstein's from daemontools Bruce Guenter's from daemontools-encore Laurent Bercot's from s6 Gerrit Pape's from runit Wayne Marshall's from perp My from nosh Tools to then process -format log file sets include, amongst others: Russ Allbery's Paul Kremer's My from nosh My from nosh Further reading Jonathan de Boyne Pollard (2…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment