rotatelogs.c revision 2e4b64595d221bd83ff057541e970c4cc737412d
/*
* Simple program to rotate Apache logs without having to kill the server.
*
* Contributed by Ben Laurie <ben@algroup.co.uk>
*
* 12 Mar 1996
*/
#define BUFSIZE 65536
#ifdef MAX_PATH
#endif
#define MAX_PATH 1024
#include "ap_config.h"
#include <time.h>
#include <errno.h>
#include <fcntl.h>
{
int nLogFD = -1;
int nRead;
char *szLogRoot;
if (argc != 3) {
"%s <logfile> <rotation time in seconds>\n\n",
argv[0]);
#ifdef OS2
argv[0]);
#else
argv[0]);
#endif
"to httpd.conf. The generated name will be /some/where.nnnn "
"where nnnn is the\nsystem time at which the log nominally "
"starts (N.B. this time will always be a\nmultiple of the "
"rotation time, so you can synchronize cron scripts with it).\n"
"At the end of each rotation time a new log is started.\n");
exit(1);
}
if (tRotation <= 0) {
exit(6);
}
for (;;) {
if (nRead == 0)
exit(3);
if (nRead < 0)
exit(4);
nLogFD = -1;
}
if (nLogFD < 0) {
if (nLogFD < 0) {
exit(2);
}
}
exit(5);
}
}
}