How do I use logrotate to remove old log tarballs?












0















I'm using Ubuntu 14.04. I want to rotate log files daily, including deleting old tarballs. I edited my logrotate.conf file, /etc/logrotate.conf, like so



/home/rails/myproject/log {
daily
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}


This has been like this for quite some time (a few months at least), but I still see tarballs from December



myuser@myproject:~$ ls -al /home/rails/myproject/log/
total 8621332
drwxr-xr-x 2 rails rails 4096 Apr 10 19:27 .
drwxr-xr-x 15 rails rails 4096 Apr 10 10:18 ..
-rw-rw-r-- 1 rails rails 0 Nov 1 16:33 development.log
-rw-rw-r-- 1 rails rails 0 Oct 22 15:12 .keep
-rw-r--r-- 1 rails rails 8583649390 Apr 10 19:09 production.log
-rw-r--r-- 1 rails rails 4213027 Dec 31 06:55 production.log.1
-rw-r--r-- 1 rails rails 887381 Dec 13 06:29 production.log.10.gz
-rw-r--r-- 1 rails rails 639810 Dec 12 06:41 production.log.11.gz
-rw-r--r-- 1 rails rails 1034755 Dec 11 06:41 production.log.12.gz
-rw-r--r-- 1 rails rails 824498 Dec 10 06:28 production.log.13.gz
-rw-r--r-- 1 rails rails 686155 Dec 9 06:53 production.log.14.gz
-rw-r--r-- 1 rails rails 634700 Dec 8 06:42 production.log.15.gz
-rw-r--r-- 1 rails rails 4277 Dec 7 06:35 production.log.16.gz
-rw-r--r-- 1 rails rails 33388963 Dec 6 06:50 production.log.17.gz
-rw-r--r-- 1 rails rails 42522255 Dec 5 06:44 production.log.18.gz
-rw-r--r-- 1 rails rails 25831496 Dec 4 06:25 production.log.19.gz
-rw-r--r-- 1 rails rails 184096 Dec 3 06:45 production.log.20.gz
-rw-r--r-- 1 rails rails 313414 Dec 2 06:31 production.log.21.gz
-rw-r--r-- 1 rails rails 306576 Dec 1 06:42 production.log.22.gz
-rw-r--r-- 1 rails rails 441101 Nov 30 06:40 production.log.23.gz
-rw-r--r-- 1 rails rails 264538 Nov 29 06:27 production.log.24.gz
-rw-r--r-- 1 rails rails 1121126 Nov 28 06:31 production.log.25.gz
-rw-r--r-- 1 rails rails 13990139 Nov 27 06:35 production.log.26.gz
-rw-r--r-- 1 rails rails 34321217 Nov 26 06:38 production.log.27.gz
-rw-r--r-- 1 rails rails 10963566 Nov 25 06:53 production.log.28.gz
-rw-r--r-- 1 rails rails 69216879 Nov 24 06:29 production.log.29.gz
-rw-r--r-- 1 rails rails 2340 Dec 30 06:30 production.log.2.gz
-rw-r--r-- 1 rails rails 2624 Dec 29 06:38 production.log.3.gz
-rw-r--r-- 1 rails rails 6354 Dec 28 06:46 production.log.4.gz
-rw-r--r-- 1 rails rails 1113173 Dec 27 06:41 production.log.5.gz
-rw-r--r-- 1 rails rails 163933 Dec 16 06:30 production.log.7.gz
-rw-r--r-- 1 rails rails 309826 Dec 15 06:51 production.log.8.gz
-rw-r--r-- 1 rails rails 1070471 Dec 14 06:53 production.log.9.gz


Is there another option I need to add that will cause the older tarballs to be deleted? I'm happy if files older than 7 days are removed from the file system.










share|improve this question

























  • As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

    – Ravexina
    Apr 10 '17 at 23:37











  • When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

    – Dave
    Apr 10 '17 at 23:45











  • I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

    – Ravexina
    Apr 10 '17 at 23:47











  • THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

    – Dave
    Apr 10 '17 at 23:49











  • Run: sudo logrotate /etc/logrotate.conf, check the result.

    – Ravexina
    Apr 10 '17 at 23:56


















0















I'm using Ubuntu 14.04. I want to rotate log files daily, including deleting old tarballs. I edited my logrotate.conf file, /etc/logrotate.conf, like so



/home/rails/myproject/log {
daily
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}


This has been like this for quite some time (a few months at least), but I still see tarballs from December



myuser@myproject:~$ ls -al /home/rails/myproject/log/
total 8621332
drwxr-xr-x 2 rails rails 4096 Apr 10 19:27 .
drwxr-xr-x 15 rails rails 4096 Apr 10 10:18 ..
-rw-rw-r-- 1 rails rails 0 Nov 1 16:33 development.log
-rw-rw-r-- 1 rails rails 0 Oct 22 15:12 .keep
-rw-r--r-- 1 rails rails 8583649390 Apr 10 19:09 production.log
-rw-r--r-- 1 rails rails 4213027 Dec 31 06:55 production.log.1
-rw-r--r-- 1 rails rails 887381 Dec 13 06:29 production.log.10.gz
-rw-r--r-- 1 rails rails 639810 Dec 12 06:41 production.log.11.gz
-rw-r--r-- 1 rails rails 1034755 Dec 11 06:41 production.log.12.gz
-rw-r--r-- 1 rails rails 824498 Dec 10 06:28 production.log.13.gz
-rw-r--r-- 1 rails rails 686155 Dec 9 06:53 production.log.14.gz
-rw-r--r-- 1 rails rails 634700 Dec 8 06:42 production.log.15.gz
-rw-r--r-- 1 rails rails 4277 Dec 7 06:35 production.log.16.gz
-rw-r--r-- 1 rails rails 33388963 Dec 6 06:50 production.log.17.gz
-rw-r--r-- 1 rails rails 42522255 Dec 5 06:44 production.log.18.gz
-rw-r--r-- 1 rails rails 25831496 Dec 4 06:25 production.log.19.gz
-rw-r--r-- 1 rails rails 184096 Dec 3 06:45 production.log.20.gz
-rw-r--r-- 1 rails rails 313414 Dec 2 06:31 production.log.21.gz
-rw-r--r-- 1 rails rails 306576 Dec 1 06:42 production.log.22.gz
-rw-r--r-- 1 rails rails 441101 Nov 30 06:40 production.log.23.gz
-rw-r--r-- 1 rails rails 264538 Nov 29 06:27 production.log.24.gz
-rw-r--r-- 1 rails rails 1121126 Nov 28 06:31 production.log.25.gz
-rw-r--r-- 1 rails rails 13990139 Nov 27 06:35 production.log.26.gz
-rw-r--r-- 1 rails rails 34321217 Nov 26 06:38 production.log.27.gz
-rw-r--r-- 1 rails rails 10963566 Nov 25 06:53 production.log.28.gz
-rw-r--r-- 1 rails rails 69216879 Nov 24 06:29 production.log.29.gz
-rw-r--r-- 1 rails rails 2340 Dec 30 06:30 production.log.2.gz
-rw-r--r-- 1 rails rails 2624 Dec 29 06:38 production.log.3.gz
-rw-r--r-- 1 rails rails 6354 Dec 28 06:46 production.log.4.gz
-rw-r--r-- 1 rails rails 1113173 Dec 27 06:41 production.log.5.gz
-rw-r--r-- 1 rails rails 163933 Dec 16 06:30 production.log.7.gz
-rw-r--r-- 1 rails rails 309826 Dec 15 06:51 production.log.8.gz
-rw-r--r-- 1 rails rails 1070471 Dec 14 06:53 production.log.9.gz


Is there another option I need to add that will cause the older tarballs to be deleted? I'm happy if files older than 7 days are removed from the file system.










share|improve this question

























  • As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

    – Ravexina
    Apr 10 '17 at 23:37











  • When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

    – Dave
    Apr 10 '17 at 23:45











  • I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

    – Ravexina
    Apr 10 '17 at 23:47











  • THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

    – Dave
    Apr 10 '17 at 23:49











  • Run: sudo logrotate /etc/logrotate.conf, check the result.

    – Ravexina
    Apr 10 '17 at 23:56
















0












0








0








I'm using Ubuntu 14.04. I want to rotate log files daily, including deleting old tarballs. I edited my logrotate.conf file, /etc/logrotate.conf, like so



/home/rails/myproject/log {
daily
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}


This has been like this for quite some time (a few months at least), but I still see tarballs from December



myuser@myproject:~$ ls -al /home/rails/myproject/log/
total 8621332
drwxr-xr-x 2 rails rails 4096 Apr 10 19:27 .
drwxr-xr-x 15 rails rails 4096 Apr 10 10:18 ..
-rw-rw-r-- 1 rails rails 0 Nov 1 16:33 development.log
-rw-rw-r-- 1 rails rails 0 Oct 22 15:12 .keep
-rw-r--r-- 1 rails rails 8583649390 Apr 10 19:09 production.log
-rw-r--r-- 1 rails rails 4213027 Dec 31 06:55 production.log.1
-rw-r--r-- 1 rails rails 887381 Dec 13 06:29 production.log.10.gz
-rw-r--r-- 1 rails rails 639810 Dec 12 06:41 production.log.11.gz
-rw-r--r-- 1 rails rails 1034755 Dec 11 06:41 production.log.12.gz
-rw-r--r-- 1 rails rails 824498 Dec 10 06:28 production.log.13.gz
-rw-r--r-- 1 rails rails 686155 Dec 9 06:53 production.log.14.gz
-rw-r--r-- 1 rails rails 634700 Dec 8 06:42 production.log.15.gz
-rw-r--r-- 1 rails rails 4277 Dec 7 06:35 production.log.16.gz
-rw-r--r-- 1 rails rails 33388963 Dec 6 06:50 production.log.17.gz
-rw-r--r-- 1 rails rails 42522255 Dec 5 06:44 production.log.18.gz
-rw-r--r-- 1 rails rails 25831496 Dec 4 06:25 production.log.19.gz
-rw-r--r-- 1 rails rails 184096 Dec 3 06:45 production.log.20.gz
-rw-r--r-- 1 rails rails 313414 Dec 2 06:31 production.log.21.gz
-rw-r--r-- 1 rails rails 306576 Dec 1 06:42 production.log.22.gz
-rw-r--r-- 1 rails rails 441101 Nov 30 06:40 production.log.23.gz
-rw-r--r-- 1 rails rails 264538 Nov 29 06:27 production.log.24.gz
-rw-r--r-- 1 rails rails 1121126 Nov 28 06:31 production.log.25.gz
-rw-r--r-- 1 rails rails 13990139 Nov 27 06:35 production.log.26.gz
-rw-r--r-- 1 rails rails 34321217 Nov 26 06:38 production.log.27.gz
-rw-r--r-- 1 rails rails 10963566 Nov 25 06:53 production.log.28.gz
-rw-r--r-- 1 rails rails 69216879 Nov 24 06:29 production.log.29.gz
-rw-r--r-- 1 rails rails 2340 Dec 30 06:30 production.log.2.gz
-rw-r--r-- 1 rails rails 2624 Dec 29 06:38 production.log.3.gz
-rw-r--r-- 1 rails rails 6354 Dec 28 06:46 production.log.4.gz
-rw-r--r-- 1 rails rails 1113173 Dec 27 06:41 production.log.5.gz
-rw-r--r-- 1 rails rails 163933 Dec 16 06:30 production.log.7.gz
-rw-r--r-- 1 rails rails 309826 Dec 15 06:51 production.log.8.gz
-rw-r--r-- 1 rails rails 1070471 Dec 14 06:53 production.log.9.gz


Is there another option I need to add that will cause the older tarballs to be deleted? I'm happy if files older than 7 days are removed from the file system.










share|improve this question
















I'm using Ubuntu 14.04. I want to rotate log files daily, including deleting old tarballs. I edited my logrotate.conf file, /etc/logrotate.conf, like so



/home/rails/myproject/log {
daily
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}


This has been like this for quite some time (a few months at least), but I still see tarballs from December



myuser@myproject:~$ ls -al /home/rails/myproject/log/
total 8621332
drwxr-xr-x 2 rails rails 4096 Apr 10 19:27 .
drwxr-xr-x 15 rails rails 4096 Apr 10 10:18 ..
-rw-rw-r-- 1 rails rails 0 Nov 1 16:33 development.log
-rw-rw-r-- 1 rails rails 0 Oct 22 15:12 .keep
-rw-r--r-- 1 rails rails 8583649390 Apr 10 19:09 production.log
-rw-r--r-- 1 rails rails 4213027 Dec 31 06:55 production.log.1
-rw-r--r-- 1 rails rails 887381 Dec 13 06:29 production.log.10.gz
-rw-r--r-- 1 rails rails 639810 Dec 12 06:41 production.log.11.gz
-rw-r--r-- 1 rails rails 1034755 Dec 11 06:41 production.log.12.gz
-rw-r--r-- 1 rails rails 824498 Dec 10 06:28 production.log.13.gz
-rw-r--r-- 1 rails rails 686155 Dec 9 06:53 production.log.14.gz
-rw-r--r-- 1 rails rails 634700 Dec 8 06:42 production.log.15.gz
-rw-r--r-- 1 rails rails 4277 Dec 7 06:35 production.log.16.gz
-rw-r--r-- 1 rails rails 33388963 Dec 6 06:50 production.log.17.gz
-rw-r--r-- 1 rails rails 42522255 Dec 5 06:44 production.log.18.gz
-rw-r--r-- 1 rails rails 25831496 Dec 4 06:25 production.log.19.gz
-rw-r--r-- 1 rails rails 184096 Dec 3 06:45 production.log.20.gz
-rw-r--r-- 1 rails rails 313414 Dec 2 06:31 production.log.21.gz
-rw-r--r-- 1 rails rails 306576 Dec 1 06:42 production.log.22.gz
-rw-r--r-- 1 rails rails 441101 Nov 30 06:40 production.log.23.gz
-rw-r--r-- 1 rails rails 264538 Nov 29 06:27 production.log.24.gz
-rw-r--r-- 1 rails rails 1121126 Nov 28 06:31 production.log.25.gz
-rw-r--r-- 1 rails rails 13990139 Nov 27 06:35 production.log.26.gz
-rw-r--r-- 1 rails rails 34321217 Nov 26 06:38 production.log.27.gz
-rw-r--r-- 1 rails rails 10963566 Nov 25 06:53 production.log.28.gz
-rw-r--r-- 1 rails rails 69216879 Nov 24 06:29 production.log.29.gz
-rw-r--r-- 1 rails rails 2340 Dec 30 06:30 production.log.2.gz
-rw-r--r-- 1 rails rails 2624 Dec 29 06:38 production.log.3.gz
-rw-r--r-- 1 rails rails 6354 Dec 28 06:46 production.log.4.gz
-rw-r--r-- 1 rails rails 1113173 Dec 27 06:41 production.log.5.gz
-rw-r--r-- 1 rails rails 163933 Dec 16 06:30 production.log.7.gz
-rw-r--r-- 1 rails rails 309826 Dec 15 06:51 production.log.8.gz
-rw-r--r-- 1 rails rails 1070471 Dec 14 06:53 production.log.9.gz


Is there another option I need to add that will cause the older tarballs to be deleted? I'm happy if files older than 7 days are removed from the file system.







tar archive rm logs logrotate






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 hours ago









anonymous2

3,34241849




3,34241849










asked Apr 10 '17 at 23:31









DaveDave

3403617




3403617













  • As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

    – Ravexina
    Apr 10 '17 at 23:37











  • When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

    – Dave
    Apr 10 '17 at 23:45











  • I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

    – Ravexina
    Apr 10 '17 at 23:47











  • THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

    – Dave
    Apr 10 '17 at 23:49











  • Run: sudo logrotate /etc/logrotate.conf, check the result.

    – Ravexina
    Apr 10 '17 at 23:56





















  • As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

    – Ravexina
    Apr 10 '17 at 23:37











  • When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

    – Dave
    Apr 10 '17 at 23:45











  • I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

    – Ravexina
    Apr 10 '17 at 23:47











  • THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

    – Dave
    Apr 10 '17 at 23:49











  • Run: sudo logrotate /etc/logrotate.conf, check the result.

    – Ravexina
    Apr 10 '17 at 23:56



















As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

– Ravexina
Apr 10 '17 at 23:37





As I know rotate 4 should do the work, man page says: log files are rotated count times before being removed. remove the old ones your config will do the rest.

– Ravexina
Apr 10 '17 at 23:37













When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

– Dave
Apr 10 '17 at 23:45





When you say " remove the old ones your config will do the rest", do you mean I need to manually delete old files? I would like to configure the logrotate program so that it does it for me. That's a pain to have to periodically login every few days and manually delete files.

– Dave
Apr 10 '17 at 23:45













I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

– Ravexina
Apr 10 '17 at 23:47





I meant for first time, after that it will only keep 4 copy of them. maybe there is a config to do this but I'm not aware of that.

– Ravexina
Apr 10 '17 at 23:47













THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

– Dave
Apr 10 '17 at 23:49





THis config has been like this for a while -- a couple of months at least. I'm pretty sure the logrotate program got these files into the .tar.gz form, but I'm not sure why it didn't delete them. Do you know?

– Dave
Apr 10 '17 at 23:49













Run: sudo logrotate /etc/logrotate.conf, check the result.

– Ravexina
Apr 10 '17 at 23:56







Run: sudo logrotate /etc/logrotate.conf, check the result.

– Ravexina
Apr 10 '17 at 23:56












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f903383%2fhow-do-i-use-logrotate-to-remove-old-log-tarballs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f903383%2fhow-do-i-use-logrotate-to-remove-old-log-tarballs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

香粉寮

GameSpot