Logrotate in linux to handle log data loss
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
We are using linux logrotate for rotating our log files,
Example :
/location/tomcat/logs/* /location/jboss/log/*
copytruncate
daily
rotate 10
compress
size 20M
olddir rotated
create 0644 test test
As per the copy truncate definition given in LINUX,
copytruncate
Truncate the original log file in place after creating a copy,
instead of moving the old log file and optionally creating a new
one, It can be used when some program can not be told to close
its logfile and thus might continue writing (appending) to the
previous log file forever. Note that there is a very small time
slice between copying the file and truncating it, so some log-
ging data might be lost. When this option is used, the create
option will have no effect, as the old log file stays in place.
So there will be a data loss in log file during rotate process. I noticed around 5 to 20 seconds of log loss, Is there a way / configuration to do the same process without data loss?
logs logrotate
add a comment |Â
up vote
2
down vote
favorite
We are using linux logrotate for rotating our log files,
Example :
/location/tomcat/logs/* /location/jboss/log/*
copytruncate
daily
rotate 10
compress
size 20M
olddir rotated
create 0644 test test
As per the copy truncate definition given in LINUX,
copytruncate
Truncate the original log file in place after creating a copy,
instead of moving the old log file and optionally creating a new
one, It can be used when some program can not be told to close
its logfile and thus might continue writing (appending) to the
previous log file forever. Note that there is a very small time
slice between copying the file and truncating it, so some log-
ging data might be lost. When this option is used, the create
option will have no effect, as the old log file stays in place.
So there will be a data loss in log file during rotate process. I noticed around 5 to 20 seconds of log loss, Is there a way / configuration to do the same process without data loss?
logs logrotate
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
We are using linux logrotate for rotating our log files,
Example :
/location/tomcat/logs/* /location/jboss/log/*
copytruncate
daily
rotate 10
compress
size 20M
olddir rotated
create 0644 test test
As per the copy truncate definition given in LINUX,
copytruncate
Truncate the original log file in place after creating a copy,
instead of moving the old log file and optionally creating a new
one, It can be used when some program can not be told to close
its logfile and thus might continue writing (appending) to the
previous log file forever. Note that there is a very small time
slice between copying the file and truncating it, so some log-
ging data might be lost. When this option is used, the create
option will have no effect, as the old log file stays in place.
So there will be a data loss in log file during rotate process. I noticed around 5 to 20 seconds of log loss, Is there a way / configuration to do the same process without data loss?
logs logrotate
We are using linux logrotate for rotating our log files,
Example :
/location/tomcat/logs/* /location/jboss/log/*
copytruncate
daily
rotate 10
compress
size 20M
olddir rotated
create 0644 test test
As per the copy truncate definition given in LINUX,
copytruncate
Truncate the original log file in place after creating a copy,
instead of moving the old log file and optionally creating a new
one, It can be used when some program can not be told to close
its logfile and thus might continue writing (appending) to the
previous log file forever. Note that there is a very small time
slice between copying the file and truncating it, so some log-
ging data might be lost. When this option is used, the create
option will have no effect, as the old log file stays in place.
So there will be a data loss in log file during rotate process. I noticed around 5 to 20 seconds of log loss, Is there a way / configuration to do the same process without data loss?
logs logrotate
logs logrotate
edited Mar 7 '17 at 13:18
John
173
173
asked Mar 6 '17 at 12:16
user219407
111
111
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
I know that in syslog-ng, you can set the output filename to use variables, including things like the date, so it would automatically start writing to a new file at 12:00am on the new day, with zero loss.
It requires changing your syslog program to syslog-ng, though. But the flexibility sounds like exactly what you need.
add a comment |Â
up vote
0
down vote
You could move from logfile logging and rotating with logrotate
to journald
logging using systemd-cat -t indentifier cmdline
. Setup log/entry sizes in /etc/systemd/journald.conf
or use journalctl --vacuum-size=, --vacuum-time=, --vacuum-files=
Another way is to logrotate
once a day by using the prerotate/postrotate feature to stop the servers, rotate the log and start the servers again. The logrotation time is depending on your systemd logrotate.timer
or (ana)cron job, which could be timed to 4am or whenever is low to zero traffic.
prerotate
# stop jboss/tomcat server
endscript
daily
rotate 10
compress
size 20M
postrotate
#start servers
endscript
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
add a comment |Â
up vote
0
down vote
This is how I do it for Catalina
logs:
/var/log/tomcat/catalina.out xargs kill -9
cat /var/log/tomcat/tmp.log >> /var/log/tomcat/catalina.out
rm /var/log/tomcat/tmp.log -f
endscript
You may optionally specify -s
with tail
to decrease refresh interval of tail
command itself. And because you use -c
option, it's fast.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I know that in syslog-ng, you can set the output filename to use variables, including things like the date, so it would automatically start writing to a new file at 12:00am on the new day, with zero loss.
It requires changing your syslog program to syslog-ng, though. But the flexibility sounds like exactly what you need.
add a comment |Â
up vote
1
down vote
I know that in syslog-ng, you can set the output filename to use variables, including things like the date, so it would automatically start writing to a new file at 12:00am on the new day, with zero loss.
It requires changing your syslog program to syslog-ng, though. But the flexibility sounds like exactly what you need.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I know that in syslog-ng, you can set the output filename to use variables, including things like the date, so it would automatically start writing to a new file at 12:00am on the new day, with zero loss.
It requires changing your syslog program to syslog-ng, though. But the flexibility sounds like exactly what you need.
I know that in syslog-ng, you can set the output filename to use variables, including things like the date, so it would automatically start writing to a new file at 12:00am on the new day, with zero loss.
It requires changing your syslog program to syslog-ng, though. But the flexibility sounds like exactly what you need.
answered Mar 6 '17 at 19:28
Aakin
112
112
add a comment |Â
add a comment |Â
up vote
0
down vote
You could move from logfile logging and rotating with logrotate
to journald
logging using systemd-cat -t indentifier cmdline
. Setup log/entry sizes in /etc/systemd/journald.conf
or use journalctl --vacuum-size=, --vacuum-time=, --vacuum-files=
Another way is to logrotate
once a day by using the prerotate/postrotate feature to stop the servers, rotate the log and start the servers again. The logrotation time is depending on your systemd logrotate.timer
or (ana)cron job, which could be timed to 4am or whenever is low to zero traffic.
prerotate
# stop jboss/tomcat server
endscript
daily
rotate 10
compress
size 20M
postrotate
#start servers
endscript
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
add a comment |Â
up vote
0
down vote
You could move from logfile logging and rotating with logrotate
to journald
logging using systemd-cat -t indentifier cmdline
. Setup log/entry sizes in /etc/systemd/journald.conf
or use journalctl --vacuum-size=, --vacuum-time=, --vacuum-files=
Another way is to logrotate
once a day by using the prerotate/postrotate feature to stop the servers, rotate the log and start the servers again. The logrotation time is depending on your systemd logrotate.timer
or (ana)cron job, which could be timed to 4am or whenever is low to zero traffic.
prerotate
# stop jboss/tomcat server
endscript
daily
rotate 10
compress
size 20M
postrotate
#start servers
endscript
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You could move from logfile logging and rotating with logrotate
to journald
logging using systemd-cat -t indentifier cmdline
. Setup log/entry sizes in /etc/systemd/journald.conf
or use journalctl --vacuum-size=, --vacuum-time=, --vacuum-files=
Another way is to logrotate
once a day by using the prerotate/postrotate feature to stop the servers, rotate the log and start the servers again. The logrotation time is depending on your systemd logrotate.timer
or (ana)cron job, which could be timed to 4am or whenever is low to zero traffic.
prerotate
# stop jboss/tomcat server
endscript
daily
rotate 10
compress
size 20M
postrotate
#start servers
endscript
You could move from logfile logging and rotating with logrotate
to journald
logging using systemd-cat -t indentifier cmdline
. Setup log/entry sizes in /etc/systemd/journald.conf
or use journalctl --vacuum-size=, --vacuum-time=, --vacuum-files=
Another way is to logrotate
once a day by using the prerotate/postrotate feature to stop the servers, rotate the log and start the servers again. The logrotation time is depending on your systemd logrotate.timer
or (ana)cron job, which could be timed to 4am or whenever is low to zero traffic.
prerotate
# stop jboss/tomcat server
endscript
daily
rotate 10
compress
size 20M
postrotate
#start servers
endscript
answered Mar 6 '17 at 13:45
Michael D.
1,489715
1,489715
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
add a comment |Â
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
I cannot stop the server, my need is while logrotate is doing truncate I should not loose the data, Is there a way for it? Can u suggest me any configuration? @Michael D
â Harry
Mar 6 '17 at 15:10
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
is using journald an option? Read this loggly.com/blog/why-journald
â Michael D.
Mar 6 '17 at 15:22
add a comment |Â
up vote
0
down vote
This is how I do it for Catalina
logs:
/var/log/tomcat/catalina.out xargs kill -9
cat /var/log/tomcat/tmp.log >> /var/log/tomcat/catalina.out
rm /var/log/tomcat/tmp.log -f
endscript
You may optionally specify -s
with tail
to decrease refresh interval of tail
command itself. And because you use -c
option, it's fast.
add a comment |Â
up vote
0
down vote
This is how I do it for Catalina
logs:
/var/log/tomcat/catalina.out xargs kill -9
cat /var/log/tomcat/tmp.log >> /var/log/tomcat/catalina.out
rm /var/log/tomcat/tmp.log -f
endscript
You may optionally specify -s
with tail
to decrease refresh interval of tail
command itself. And because you use -c
option, it's fast.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This is how I do it for Catalina
logs:
/var/log/tomcat/catalina.out xargs kill -9
cat /var/log/tomcat/tmp.log >> /var/log/tomcat/catalina.out
rm /var/log/tomcat/tmp.log -f
endscript
You may optionally specify -s
with tail
to decrease refresh interval of tail
command itself. And because you use -c
option, it's fast.
This is how I do it for Catalina
logs:
/var/log/tomcat/catalina.out xargs kill -9
cat /var/log/tomcat/tmp.log >> /var/log/tomcat/catalina.out
rm /var/log/tomcat/tmp.log -f
endscript
You may optionally specify -s
with tail
to decrease refresh interval of tail
command itself. And because you use -c
option, it's fast.
edited Aug 16 at 6:37
answered Aug 15 at 8:31
Alireza Mohamadi
10816
10816
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f349471%2flogrotate-in-linux-to-handle-log-data-loss%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password