Daily compress log files not working
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
This is the log file I am using to compress log files on a daily basis.
/home/ubuntu/logs/server.log
daily
missingok
rotate 1
compress
create
dateext
dateyesterday
dateformat .%Y-%m-%d
extension .gz
postrotate
mv /home/ubuntu/logs/*.gz /home/ubuntu/zip/
endscript
When I run with the --force
option, I don't see the zipped file. I can see only the date extension applied to the file. Here is the result of running the command
logrotate /home/ubuntu/conf/logrotate.conf --state /home/ubuntu/conf/logrotate.state --verbose --force
Result:
rotating pattern: /home/ubuntu/logs/server.log forced from command line (1 rotations)
empty log files are rotated, old logs are removed
considering log /home/ubuntu/logs/server.log
log needs rotating
rotating log /home/ubuntu/logs/server.log, log->rotateCount is 1
Converted ' .%Y-%m-%d' -> '.%Y-%m-%d'
dateext suffix '.2018-03-04'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
renaming /home/ubuntu/logs/server.log to /home/ubuntu/logs/server.log.2018-03-04
creating new /home/ubuntu/logs/server.log mode = 0664 uid = 1000 gid = 1000
running postrotate script
mv: cannot stat '/home/ubuntu/logs/*.gz': No such file or directory
error: error running non-shared postrotate script for /home/ubuntu/logs/server.log of '/home/ubuntu/logs/server.log '
How do I ensure that the log file created yesterday is zipped off and a new, empty one is created for today?
cron logging logrotate
add a comment |Â
up vote
1
down vote
favorite
This is the log file I am using to compress log files on a daily basis.
/home/ubuntu/logs/server.log
daily
missingok
rotate 1
compress
create
dateext
dateyesterday
dateformat .%Y-%m-%d
extension .gz
postrotate
mv /home/ubuntu/logs/*.gz /home/ubuntu/zip/
endscript
When I run with the --force
option, I don't see the zipped file. I can see only the date extension applied to the file. Here is the result of running the command
logrotate /home/ubuntu/conf/logrotate.conf --state /home/ubuntu/conf/logrotate.state --verbose --force
Result:
rotating pattern: /home/ubuntu/logs/server.log forced from command line (1 rotations)
empty log files are rotated, old logs are removed
considering log /home/ubuntu/logs/server.log
log needs rotating
rotating log /home/ubuntu/logs/server.log, log->rotateCount is 1
Converted ' .%Y-%m-%d' -> '.%Y-%m-%d'
dateext suffix '.2018-03-04'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
renaming /home/ubuntu/logs/server.log to /home/ubuntu/logs/server.log.2018-03-04
creating new /home/ubuntu/logs/server.log mode = 0664 uid = 1000 gid = 1000
running postrotate script
mv: cannot stat '/home/ubuntu/logs/*.gz': No such file or directory
error: error running non-shared postrotate script for /home/ubuntu/logs/server.log of '/home/ubuntu/logs/server.log '
How do I ensure that the log file created yesterday is zipped off and a new, empty one is created for today?
cron logging logrotate
If you want to move rotated logs to a different directory, there's theolddir
option.
â muru
Mar 6 at 4:16
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
For now, try getting it moved first.
â muru
Mar 6 at 4:18
I can see it moved with theolddir
command. Now usepostrotate
to compress?
â cogitoergosum
Mar 6 at 4:31
1
The manpage oflogrotate.conf
says that thepostrotate
script is run before the rotated file is compressed. It's possible thatcompress
did not work in your earlier attempt because thepostrotate
script failed.
â muru
Mar 6 at 4:33
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This is the log file I am using to compress log files on a daily basis.
/home/ubuntu/logs/server.log
daily
missingok
rotate 1
compress
create
dateext
dateyesterday
dateformat .%Y-%m-%d
extension .gz
postrotate
mv /home/ubuntu/logs/*.gz /home/ubuntu/zip/
endscript
When I run with the --force
option, I don't see the zipped file. I can see only the date extension applied to the file. Here is the result of running the command
logrotate /home/ubuntu/conf/logrotate.conf --state /home/ubuntu/conf/logrotate.state --verbose --force
Result:
rotating pattern: /home/ubuntu/logs/server.log forced from command line (1 rotations)
empty log files are rotated, old logs are removed
considering log /home/ubuntu/logs/server.log
log needs rotating
rotating log /home/ubuntu/logs/server.log, log->rotateCount is 1
Converted ' .%Y-%m-%d' -> '.%Y-%m-%d'
dateext suffix '.2018-03-04'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
renaming /home/ubuntu/logs/server.log to /home/ubuntu/logs/server.log.2018-03-04
creating new /home/ubuntu/logs/server.log mode = 0664 uid = 1000 gid = 1000
running postrotate script
mv: cannot stat '/home/ubuntu/logs/*.gz': No such file or directory
error: error running non-shared postrotate script for /home/ubuntu/logs/server.log of '/home/ubuntu/logs/server.log '
How do I ensure that the log file created yesterday is zipped off and a new, empty one is created for today?
cron logging logrotate
This is the log file I am using to compress log files on a daily basis.
/home/ubuntu/logs/server.log
daily
missingok
rotate 1
compress
create
dateext
dateyesterday
dateformat .%Y-%m-%d
extension .gz
postrotate
mv /home/ubuntu/logs/*.gz /home/ubuntu/zip/
endscript
When I run with the --force
option, I don't see the zipped file. I can see only the date extension applied to the file. Here is the result of running the command
logrotate /home/ubuntu/conf/logrotate.conf --state /home/ubuntu/conf/logrotate.state --verbose --force
Result:
rotating pattern: /home/ubuntu/logs/server.log forced from command line (1 rotations)
empty log files are rotated, old logs are removed
considering log /home/ubuntu/logs/server.log
log needs rotating
rotating log /home/ubuntu/logs/server.log, log->rotateCount is 1
Converted ' .%Y-%m-%d' -> '.%Y-%m-%d'
dateext suffix '.2018-03-04'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
renaming /home/ubuntu/logs/server.log to /home/ubuntu/logs/server.log.2018-03-04
creating new /home/ubuntu/logs/server.log mode = 0664 uid = 1000 gid = 1000
running postrotate script
mv: cannot stat '/home/ubuntu/logs/*.gz': No such file or directory
error: error running non-shared postrotate script for /home/ubuntu/logs/server.log of '/home/ubuntu/logs/server.log '
How do I ensure that the log file created yesterday is zipped off and a new, empty one is created for today?
cron logging logrotate
cron logging logrotate
edited Mar 5 at 22:37
asked Mar 5 at 16:31
cogitoergosum
1086
1086
If you want to move rotated logs to a different directory, there's theolddir
option.
â muru
Mar 6 at 4:16
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
For now, try getting it moved first.
â muru
Mar 6 at 4:18
I can see it moved with theolddir
command. Now usepostrotate
to compress?
â cogitoergosum
Mar 6 at 4:31
1
The manpage oflogrotate.conf
says that thepostrotate
script is run before the rotated file is compressed. It's possible thatcompress
did not work in your earlier attempt because thepostrotate
script failed.
â muru
Mar 6 at 4:33
add a comment |Â
If you want to move rotated logs to a different directory, there's theolddir
option.
â muru
Mar 6 at 4:16
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
For now, try getting it moved first.
â muru
Mar 6 at 4:18
I can see it moved with theolddir
command. Now usepostrotate
to compress?
â cogitoergosum
Mar 6 at 4:31
1
The manpage oflogrotate.conf
says that thepostrotate
script is run before the rotated file is compressed. It's possible thatcompress
did not work in your earlier attempt because thepostrotate
script failed.
â muru
Mar 6 at 4:33
If you want to move rotated logs to a different directory, there's the
olddir
option.â muru
Mar 6 at 4:16
If you want to move rotated logs to a different directory, there's the
olddir
option.â muru
Mar 6 at 4:16
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
For now, try getting it moved first.
â muru
Mar 6 at 4:18
For now, try getting it moved first.
â muru
Mar 6 at 4:18
I can see it moved with the
olddir
command. Now use postrotate
to compress?â cogitoergosum
Mar 6 at 4:31
I can see it moved with the
olddir
command. Now use postrotate
to compress?â cogitoergosum
Mar 6 at 4:31
1
1
The manpage of
logrotate.conf
says that the postrotate
script is run before the rotated file is compressed. It's possible that compress
did not work in your earlier attempt because the postrotate
script failed.â muru
Mar 6 at 4:33
The manpage of
logrotate.conf
says that the postrotate
script is run before the rotated file is compressed. It's possible that compress
did not work in your earlier attempt because the postrotate
script failed.â muru
Mar 6 at 4:33
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2faskubuntu.com%2fquestions%2f1012123%2fdaily-compress-log-files-not-working%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
If you want to move rotated logs to a different directory, there's the
olddir
option.â muru
Mar 6 at 4:16
I want to zip and move it to a different directory. For now, I am not even able to get the log files zipped on a daily basis.
â cogitoergosum
Mar 6 at 4:17
For now, try getting it moved first.
â muru
Mar 6 at 4:18
I can see it moved with the
olddir
command. Now usepostrotate
to compress?â cogitoergosum
Mar 6 at 4:31
1
The manpage of
logrotate.conf
says that thepostrotate
script is run before the rotated file is compressed. It's possible thatcompress
did not work in your earlier attempt because thepostrotate
script failed.â muru
Mar 6 at 4:33