{
    "content": [
        {
            "type": "text",
            "text": "# rotatelogs (man)\n\n## NAME\n\nrotatelogs - Piped logging program to rotate Apache logs\n\n## SYNOPSIS\n\nrotatelogs  [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -D ] [ -t ] [ -v ] [ -e ] [ -c ] [\n-n number-of-files ] logfile rotationtime|filesize(B|K|M|G) [ offset ]\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **SUMMARY**\n- **OPTIONS** (10 subsections)\n- **EXAMPLES**\n- **PORTABILITY**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "rotatelogs",
        "section": "",
        "mode": "man",
        "summary": "rotatelogs - Piped logging program to rotate Apache logs",
        "synopsis": "rotatelogs  [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -D ] [ -t ] [ -v ] [ -e ] [ -c ] [\n-n number-of-files ] logfile rotationtime|filesize(B|K|M|G) [ offset ]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-l",
                "long": null,
                "arg": null,
                "description": "time(3) formatting with size-based rotation."
            },
            {
                "flag": "-L",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-p",
                "long": null,
                "arg": null,
                "description": "If given, rotatelogs will execute the specified program every time a new log file is opened. The filename of the newly opened file is passed as the first argument to the program. If executing after a rotation, the old log file is passed as the second argu‐ ment. rotatelogs does not wait for the specified program to terminate before continu‐ ing to operate, and will not log any error code returned on termination. The spawned program uses the same stdin, stdout, and stderr as rotatelogs itself, and also inher‐ its the environment."
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "waiting for the first logfile entry to be read (for non-busy sites, there may be a substantial delay between when the server is started and when the first request is handled, meaning that the associated logfile does not \"exist\" until then, which causes problems from some automated logging tools)"
            },
            {
                "flag": "-D",
                "long": null,
                "arg": null,
                "description": "do not already exist. This allows strftime(3) formatting to be used in the path and not just the filename."
            },
            {
                "flag": "-t",
                "long": null,
                "arg": null,
                "description": "processed in real time by a command like tail, and there is no need for archived data. No suffix will be added to the filename, however format strings containing '%' charac‐ ters will be respected."
            },
            {
                "flag": "-v",
                "long": null,
                "arg": null,
                "description": "parsing, and all file open and close actions."
            },
            {
                "flag": "-e",
                "long": null,
                "arg": null,
                "description": "time by a further tool in the chain."
            },
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-n",
                "long": null,
                "arg": null,
                "description": "Use a circular list of filenames without timestamps. With -n 3, the series of log files opened would be \"logfile\", \"logfile.1\", \"logfile.2\", then overwriting \"logfile\". Available in 2.4.5 and later. logfile rotationtime The time between log file rotations in seconds. The rotation occurs at the beginning of this interval. For example, if the rotation time is 3600, the log file will be ro‐ tated at the beginning of every hour; if the rotation time is 86400, the log file will be rotated every night at midnight. (If no data is logged during an interval, no file will be created.) filesize(B|K|M|G) The maximum file size in followed by exactly one of the letters B (Bytes), K (KBytes), M (MBytes) or G (GBytes). .PP When time and size are specified, the size must be given after the time. Rotation will occur whenever either time or size limits are reached. offset The number of minutes offset from UTC. If omitted, zero is assumed and UTC is used. For example, to use local time in the zone UTC -5 hours, specify a value of -300 for this argument. In most cases, -l should be used instead of specifying an offset."
            }
        ],
        "examples": [
            "CustomLog \"|bin/rotatelogs /var/log/logfile 86400\" common",
            "This  creates  the files /var/log/logfile.nnnn where nnnn is the system time at which the log",
            "nominally starts (this time will always be a multiple of the rotation time, so you  can  syn‐",
            "chronize  cron scripts with it). At the end of each rotation time (here after 24 hours) a new",
            "log is started.",
            "CustomLog \"|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400\" common",
            "This creates the files /var/log/logfile.yyyy.mm.dd where yyyy is the year, mm is  the  month,",
            "and  dd is the day of the month. Logging will switch to a new file every day at midnight, lo‐",
            "cal time.",
            "CustomLog \"|bin/rotatelogs /var/log/logfile 5M\" common",
            "This configuration will rotate the logfile whenever it reaches a size of 5 megabytes.",
            "ErrorLog \"|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H%M%S 5M\"",
            "This configuration will rotate the error logfile whenever it reaches a size of  5  megabytes,",
            "and the suffix to the logfile name will be created of the form errorlog.YYYY-mm-dd-HHMMSS.",
            "CustomLog \"|bin/rotatelogs -t /var/log/logfile 86400\" common",
            "This  creates  the  file /var/log/logfile, truncating the file at startup and then truncating",
            "the file once per day. It is expected in this scenario that a separate process (such as tail)",
            "would process the file in real time."
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SUMMARY",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-l",
                        "lines": 2,
                        "flag": "-l"
                    },
                    {
                        "name": "-L",
                        "lines": 1,
                        "flag": "-L"
                    },
                    {
                        "name": "-p",
                        "lines": 8,
                        "flag": "-p"
                    },
                    {
                        "name": "-f",
                        "lines": 5,
                        "flag": "-f"
                    },
                    {
                        "name": "-D",
                        "lines": 3,
                        "flag": "-D"
                    },
                    {
                        "name": "-t",
                        "lines": 4,
                        "flag": "-t"
                    },
                    {
                        "name": "-v",
                        "lines": 2,
                        "flag": "-v"
                    },
                    {
                        "name": "-e",
                        "lines": 2,
                        "flag": "-e"
                    },
                    {
                        "name": "-c",
                        "lines": 1,
                        "flag": "-c"
                    },
                    {
                        "name": "-n",
                        "lines": 23,
                        "flag": "-n"
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 43,
                "subsections": []
            },
            {
                "name": "PORTABILITY",
                "lines": 73,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "rotatelogs - Piped logging program to rotate Apache logs\n\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "rotatelogs  [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -D ] [ -t ] [ -v ] [ -e ] [ -c ] [\n-n number-of-files ] logfile rotationtime|filesize(B|K|M|G) [ offset ]\n\n\n",
                "subsections": []
            },
            "SUMMARY": {
                "content": "rotatelogs is a simple program for use in conjunction with Apache's piped logfile feature. It\nsupports rotation based on a time interval or maximum size of the log.\n\n\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-l",
                        "content": "time(3) formatting with size-based rotation.\n",
                        "flag": "-l"
                    },
                    {
                        "name": "-L",
                        "content": "",
                        "flag": "-L"
                    },
                    {
                        "name": "-p",
                        "content": "If given, rotatelogs will execute the specified program every time a new log  file  is\nopened.  The  filename of the newly opened file is passed as the first argument to the\nprogram. If executing after a rotation, the old log file is passed as the second argu‐\nment.  rotatelogs does not wait for the specified program to terminate before continu‐\ning to operate, and will not log any error code returned on termination.  The  spawned\nprogram  uses the same stdin, stdout, and stderr as rotatelogs itself, and also inher‐\nits the environment.\n",
                        "flag": "-p"
                    },
                    {
                        "name": "-f",
                        "content": "waiting  for  the  first  logfile entry to be read (for non-busy sites, there may be a\nsubstantial delay between when the server is started and when  the  first  request  is\nhandled, meaning that the associated logfile does not \"exist\" until then, which causes\nproblems from some automated logging tools)\n",
                        "flag": "-f"
                    },
                    {
                        "name": "-D",
                        "content": "do  not  already  exist. This allows strftime(3) formatting to be used in the path and\nnot just the filename.\n",
                        "flag": "-D"
                    },
                    {
                        "name": "-t",
                        "content": "processed in real time by a command like tail, and there is no need for archived data.\nNo suffix will be added to the filename, however format strings containing '%' charac‐\nters will be respected.\n",
                        "flag": "-t"
                    },
                    {
                        "name": "-v",
                        "content": "parsing, and all file open and close actions.\n",
                        "flag": "-v"
                    },
                    {
                        "name": "-e",
                        "content": "time by a further tool in the chain.\n",
                        "flag": "-e"
                    },
                    {
                        "name": "-c",
                        "content": "",
                        "flag": "-c"
                    },
                    {
                        "name": "-n",
                        "content": "Use  a  circular  list  of  filenames without timestamps. With -n 3, the series of log\nfiles opened would be \"logfile\", \"logfile.1\", \"logfile.2\", then overwriting \"logfile\".\nAvailable in 2.4.5 and later.\n\nlogfile\n\nrotationtime\nThe  time  between log file rotations in seconds. The rotation occurs at the beginning\nof this interval. For example, if the rotation time is 3600, the log file will be  ro‐\ntated at the beginning of every hour; if the rotation time is 86400, the log file will\nbe rotated every night at midnight. (If no data is logged during an interval, no  file\nwill be created.)\n\nfilesize(B|K|M|G)\nThe maximum file size in followed by exactly one of the letters B (Bytes), K (KBytes),\nM (MBytes) or G (GBytes). .PP When time and size are specified, the size must be given\nafter the time. Rotation will occur whenever either time or size limits are reached.\n\noffset The  number  of  minutes offset from UTC. If omitted, zero is assumed and UTC is used.\nFor example, to use local time in the zone UTC -5 hours, specify a value of  -300  for\nthis argument. In most cases, -l should be used instead of specifying an offset.\n\n",
                        "flag": "-n"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "CustomLog \"|bin/rotatelogs /var/log/logfile 86400\" common\n\n\n\nThis  creates  the files /var/log/logfile.nnnn where nnnn is the system time at which the log\nnominally starts (this time will always be a multiple of the rotation time, so you  can  syn‐\nchronize  cron scripts with it). At the end of each rotation time (here after 24 hours) a new\nlog is started.\n\n\nCustomLog \"|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400\" common\n\n\n\nThis creates the files /var/log/logfile.yyyy.mm.dd where yyyy is the year, mm is  the  month,\nand  dd is the day of the month. Logging will switch to a new file every day at midnight, lo‐\ncal time.\n\n\nCustomLog \"|bin/rotatelogs /var/log/logfile 5M\" common\n\n\n\nThis configuration will rotate the logfile whenever it reaches a size of 5 megabytes.\n\n\nErrorLog \"|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H%M%S 5M\"\n\n\n\nThis configuration will rotate the error logfile whenever it reaches a size of  5  megabytes,\nand the suffix to the logfile name will be created of the form errorlog.YYYY-mm-dd-HHMMSS.\n\n\nCustomLog \"|bin/rotatelogs -t /var/log/logfile 86400\" common\n\n\n\nThis  creates  the  file /var/log/logfile, truncating the file at startup and then truncating\nthe file once per day. It is expected in this scenario that a separate process (such as tail)\nwould process the file in real time.\n\n",
                "subsections": []
            },
            "PORTABILITY": {
                "content": "The  following logfile format string substitutions should be supported by all strftime(3) im‐\nplementations, see the strftime(3) man page for library-specific extensions.\n\n\n• %A - full weekday name (localized)\n\n\n• %a - 3-character weekday name (localized)\n\n\n• %B - full month name (localized)\n\n\n• %b - 3-character month name (localized)\n\n\n• %c - date and time (localized)\n\n\n• %d - 2-digit day of month\n\n\n• %H - 2-digit hour (24 hour clock)\n\n\n• %I - 2-digit hour (12 hour clock)\n\n\n• %j - 3-digit day of year\n\n\n• %M - 2-digit minute\n\n\n• %m - 2-digit month\n\n\n• %p - am/pm of 12 hour clock (localized)\n\n\n• %S - 2-digit second\n\n\n• %U - 2-digit week of year (Sunday first day of week)\n\n\n• %W - 2-digit week of year (Monday first day of week)\n\n\n• %w - 1-digit weekday (Sunday first day of week)\n\n\n• %X - time (localized)\n\n\n• %x - date (localized)\n\n\n• %Y - 4-digit year\n\n\n• %y - 2-digit year\n\n\n• %Z - time zone name\n\n\n• %% - literal `%'\n\n\n\n\nApache HTTP Server                           2020-06-10                                ROTATELOGS(8)",
                "subsections": []
            }
        }
    }
}