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 ๐Ÿ’œ

  1. Version-numbered files get cycled ๐Ÿ”„ file.2 moves to file.3, file.1 moves to file.2, and so on. Then file.0 moves to file.1, and file itself gets deleted. Both compressed and uncompressed names get cycled, regardless of -l. Missing version files just get ignored, no drama ๐Ÿซถ
  2. The new file.1 gets compressed unless you gave -l. It's changed according to the -m, -u, and -g flags.
  3. The main file gets moved to file.0 ๐Ÿ“ฆ
  4. 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 ๐Ÿ’…).
  5. The new file.0 gets changed according to the -m, -u, and -g flags.

๐Ÿฆ‹ 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 least 2, 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 with bzip2 instead of gzip ๐Ÿ“
  • -J โ€” compress with xz instead of gzip ๐ŸŒˆ
    • 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 the date(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 to file.0, and savelog moves it to file.1 and compresses it, data could be lost. ๐Ÿ˜ญ

๐Ÿ”— SEE ALSO ๐Ÿ”—


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 ๐Ÿ’…โœจ