SAVELOG(8)
โจ SAVELOG โจ
okay bestie, meet savelog ๐ It's the manual-page crew's go-to command for "save a log file" ๐ (that's the NAME line, and yes it's giving tidy).
๐ SYNOPSIS ๐
savelog [-m mode] [-u user] [-g group] [-t] [-p] [-c cycle] [-l] [-j]
[-J] [-1 .. -9] [-C] [-d] [-l] [-r rolldir] [-n] [-q] [-D dateformat]
file ...
๐ DESCRIPTION ๐
okay so the savelog command saves and optionally compresses old copies of your files ๐ฆ Older versions get named like this:
file.<number><compress_suffix>
where number is the version number, and 0 is the newest ๐ Versions numbered above 0 get compressed unless you pass -l to stop that ๐
โโ๏ธ Version 0 is not compressed, because a process might still have the file open for I/O (bestie, that's the reason, it's not random). Only cycle versions of the file get kept โจ
If the file doesn't exist and you gave -t, savelog will create it ๐ธ
For files that do exist and have lengths greater than zero, here's the whole routine ๐
- Version-numbered files get cycled ๐
file.2moves tofile.3,file.1moves tofile.2, and so on. Thenfile.0moves tofile.1, andfileitself gets deleted. Both compressed and uncompressed names get cycled, regardless of-l. Missing version files just get ignored, no drama ๐ซถ - The new
file.1gets compressed unless you gave-l. It's changed according to the-m,-u, and-gflags. - The main file gets moved to
file.0๐ฆ - If you used
-m,-u,-g,-t, or-p, an empty file gets created with those flags applied. With-p, the new file keeps the same owner, group, and permissions as before (main character energy ๐ ). - The new
file.0gets changed according to the-m,-u, and-gflags.
๐ฆ OPTIONS ๐ฆ
-m modeโ chmod the log files to mode. Implies-t๐จ-u userโ chown the log files to user. Implies-t๐ค-g groupโ chgrp the log files to group. Implies-t๐ฅ-c cycleโ save cycle versions of the logfile (default:7). The cycle count has to be at least2, no cap ๐ข-tโ touch the new logfile into existence โจ-lโ don't compress any log files (default: do compress) ๐ โโ๏ธ-pโ preserve the owner, group, and permissions of the logfile ๐-jโ compress withbzip2instead ofgzip๐-Jโ compress withxzinstead ofgzip๐- lowkey important: no strength option gets set for xz, so xz picks its own default based on the total amount of physical RAM. Also, xz can use a very large amount of memory for the higher compression levels ๐
-1 .. -9โ compression strength or memory usage (default:9, except for xz) ๐ช-Cโ force cleanup of cycled logfiles ๐งน-dโ use the standard date for rolling ๐-D dateformatโ override the date format, using the syntax that thedate(1)command understands ๐ง-rโ use rolldir instead of.to roll files ๐-nโ do not rotate empty files ๐ซง-qโ be quiet ๐คซ
๐ BUGS ๐
bestie, heads up โ ๏ธ If a process is still writing tofile.0, and savelog moves it tofile.1and compresses it, data could be lost. ๐ญ
๐ SEE ALSO ๐
logrotate(8)๐ท
that's a wrap, bestie! ๐ง This page came from the Debian manual, dated 30 Dec 2017, and it's filed under SAVELOG(8) ๐ Stay iconic and keep your logs cycled ๐ โจ
๐ฆ where this page comes from
- debian bookworm: debianutils 5.7-0.5~deb12u1 ยท GPL-2.0-or-later
- debian trixie: debianutils 5.23.2 ยท GPL-2.0-or-later
- nixpkgs unstable: debianutils 5.23.2
- ubuntu jammy: debianutils 5.5-1ubuntu2
- ubuntu noble: debianutils 5.17build1 ยท GPL-2.0-or-later
- ubuntu questing: debianutils 5.23.2 ยท GPL-2.0-or-later
- ubuntu resolute: debianutils 5.23.2build1 ยท GPL-2.0-or-later
- ubuntu stonking: debianutils 5.24 ยท GPL-2.0-or-later
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms