ROTATELOGS(8)
π ROTATELOGS(8) π
okay bestie, gather round, because this is the rotatelogs page from section 8 of the manual β the Apache HTTP Server one β and she is so much more fun than she sounds. β¨
πΈ NAME πΈ
rotatelogs β a piped logging program that rotates Apache logs. yes, that's the whole job. she rotates. she slays. π
π SYNOPSIS π
rotatelogs [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -D ] [ -t ] [
-T ] [ -v ] [ -e ] [ -c ] [ -n number-of-files ] logfile
rotationtime|filesize(B|K|M|G) [ offset ]
look at her. all those little flags. a whole wardrobe. π
β¨ SUMMARY β¨
so rotatelogs is a simple little program that you hook up with Apache's piped logfile feature. that's the vibe. it can rotate based on either a time interval or a maximum log size β your choice, bestie, you contain multitudes. π¦
π OPTIONS π
-lβ makes the interval base (or thestrftime(3)formatting when you're doing size-based rotation) use local time instead of GMT. lowkey the move, fr fr.-L linknameβ that's it. that's the entry. the page gives you the flag and the placeholder name and then says nothing else, bestie π i'm not gonna make up lore for it, i'm just gonna hold it up like a little trophy. it's here. it exists. it takes alinkname. π-p programβ if you give this one,rotatelogswill execute the program you named every single time a new log file gets opened. the filename of the freshly opened file gets passed in as the first argument to that program. and if this is happening after a rotation, the old log file gets passed as the second argument. and here's the tea:rotatelogsdoes not wait for your program to finish before carrying on, and it will not log any error code that program returns when it dies. the spawned program shares the samestdin,stdoutandstderrasrotatelogsitself, and it also inherits the environment. π«Ά-fβ opens the logfile immediately, the secondrotatelogsstarts, instead of waiting around for the first log entry to be read. why does that matter? because on a non-busy site there can be a substantial delay between the server starting and the first request actually being handled β which means the logfile doesn't "exist" until then, and that causes problems for some automated logging tools. so-ffixes that vibe. β¨-Dβ creates the parent directories of wherever the log file is going, if they aren't already there. this is what lets you usestrftime(3)formatting in the path and not just the filename. glow up. π-tβ truncates the logfile instead of rotating it. useful when a log is being processed in real time by something liketailand you genuinely don't need archived data. heads up though: no suffix gets added to the filename, but format strings containing%characters will still be respected. π-Tβ makes all but the initial logfile get truncated when opened. this is the one for when your format string contains something that loops around, like the day of the month. available in 2.4.56 and later. π-vβ verbose output onSTDERR. it shows you the result of the configuration parsing plus every single file open and close action. she's telling you everything, bestie. π-eβ echoes logs through tostdout. perfect when the logs need to be processed further, in real time, by another tool downstream in the chain. π₯-cβ creates a log file for each interval, even if it's empty. no skipping. every interval gets a file. periodt.-n number-of-filesβ uses a circular list of filenames with no timestamps. β οΈ this option overwrites log files at startup and during rotation. with-n 3, the series of files opened would be"logfile","logfile.1","logfile.2", and then it wraps back around and overwrites"logfile". when the program first opens"logfile", that file only gets truncated if-tis also provided. every rotation after that always begins with truncating the target file. and here's your warning bestie, listen up: for size based rotation without-tand with existing log files already in place, this option can produce unintuitive behavior β like initial log entries getting sent to"logfile.1", and entries in"logfile.1"not being preserved even when later"logfile.n"files haven't been used yet. available in 2.4.5 and later. πlogfileβ yeah. that's the entry. just the name of the thing. no description given on this page, so i'm not inventing one. she's the logfile. you know her. πrotationtimeβ the time between log file rotations, in seconds. the rotation happens at the beginning of that interval. so if the rotation time is3600, the log file rotates at the beginning of every hour; if it's86400, it rotates every night at midnight. and β parenthetical moment β if no data is logged during an interval, no file will be created. πΈfilesize(B|K|M|G)β the maximum file size, followed by exactly one of these letters:B(Bytes),K(KBytes),M(MBytes) orG(GBytes). and when you specify both time and size, the size has to come after the time. rotation happens whenever either the time limit or the size limit is reached. βoffsetβ the number of minutes offset from UTC. if you omit it, zero is assumed and UTC is used. for example, to use local time in the zone UTC -5 hours, you'd specify a value of-300for this argument. but ngl, in most cases you should be using-linstead of specifying an offset. π
π¦ EXAMPLES π¦
CustomLog "|bin/rotatelogs /var/log/logfile 86400" common
this creates files at /var/log/logfile.nnnn, where nnnn is the system time at which the log nominally starts. (and bestie, that time will always be a multiple of the rotation time, which means you can synchronize your cron scripts with it. iconic.) at the end of each rotation time β here, after 24 hours β a new log starts. π
CustomLog "|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400" common
this creates files at /var/log/logfile.yyyy.mm.dd, where yyyy is the year, mm is the month, and dd is the day of the month. logging switches to a new file every day at midnight, local time. obsessed. β¨
CustomLog "|bin/rotatelogs /var/log/logfile 5M" common
this config rotates the logfile whenever it hits a size of 5 megabytes. simple. clean. slay. π
ErrorLog "|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H_%M_%S 5M"
this rotates the error logfile whenever it reaches 5 megabytes, and the suffix on the logfile name gets built in the form errorlog.YYYY-mm-dd-HH_MM_SS. π₯
CustomLog "|bin/rotatelogs -t /var/log/logfile 86400" common
this creates the file /var/log/logfile, truncating it at startup and then truncating it once per day. in this scenario it's expected that a separate process β like tail β would process that file in real time. π
CustomLog "|bin/rotatelogs -T /var/log/logfile.%d 86400" common
if the server is started (or restarted) on the first of the month, this appends to /var/log/logfile.01. when a log entry gets written on the second of the month, /var/log/logfile.02 is truncated and new entries are added to the top. this example keeps roughly 1 month's worth of logs with no external maintenance needed. she's self-sufficient. main character energy. π
π PORTABILITY π
the following logfile format string substitutions should be supported by all strftime(3) implementations. for library-specific extensions, go check the strftime(3) man page. π«Ά
%A- full weekday name (localized)%a- 3-character weekday name (localized)%B- full month name (localized)%b- 3-character month name (localized)%c- date and time (localized)%d- 2-digit day of month%H- 2-digit hour (24 hour clock)%I- 2-digit hour (12 hour clock)%j- 3-digit day of year%M- 2-digit minute%m- 2-digit month%p- am/pm of 12 hour clock (localized)%S- 2-digit second%U- 2-digit week of year (Sunday first day of week)%W- 2-digit week of year (Monday first day of week)%w- 1-digit weekday (Sunday first day of week)%X- time (localized)%x- date (localized)%Y- 4-digit year%y- 2-digit year%Z- time zone name%%- literal%
and that's the whole page, bestie!! π this one came from the Apache HTTP Server, dated 2026-04-30, and it lives in the ROTATELOGS(8) section. go rotate something. i believe in you. periodt. πΈβ¨ππ¦π
π¦ where this page comes from
- alpine 3.22: apache2-doc 2.4.69-r0 Β· Apache-2.0
- alpine 3.23: apache2-doc 2.4.69-r0 Β· Apache-2.0
- alpine 3.24: apache2-doc 2.4.69-r0 Β· Apache-2.0
- arch rolling: apache 2.4.69-1 Β· Apache-2.0
- debian bookworm: apache2-utils 2.4.68-1~deb12u1 Β· Apache-2.0
- debian trixie: apache2-utils 2.4.68-1~deb13u1 Β· Apache-2.0
- debian trixie: apache2-utils 2.4.69-1~deb13u1 Β· Apache-2.0
- fedora 43: httpd 2.4.68-1.fc43
- fedora 43: httpd 2.4.69-1.fc43 Β· Apache-2.0 AND (BSD-3-Clause AND metamail AND HPND-sell-variant AND Spencer-94)
- fedora 44: httpd 2.4.69-1.fc44 Β· Apache-2.0 AND (BSD-3-Clause AND metamail AND HPND-sell-variant AND Spencer-94)
- nixpkgs unstable: apache-httpd 2.4.69
- ubuntu stonking: apache2-utils 2.4.68-1ubuntu4 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms