Code Monkey home page Code Monkey logo

logrotate's People

Contributors

bhperry avatar chrif avatar msh100 avatar ravikumawat7716 avatar yan234280533 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

logrotate's Issues

New release please!

We'd love to be able to use a pinned version of logrotate - mostly so we don't run latest - and a new release would be greatly appreciated :)

Compression doesn't seem to work using docker-compose

I'm using this in my docker-compose.yml:

 logrotate:                                                                                                                                                        
    image: "blacklabelops/logrotate"                                                                                                                                
    volumes:                                                                                                                                                        
      - /var/lib/docker/containers:/var/lib/docker/containers                                                                                                       
    environment:                                                                                                                                                    
      - LOGS_DIRECTORIES=/var/lib/docker/containers                                                                                                                 
      - LOGROTATE_INTERVAL=hourly                                                                                                                                   
      - LOGROTATE_COPIES=7                                                                                                                                          
      - LOGROTATE_SIZE=10M                                                                                                                                          
      - LOGROTATE_COMPRESSION=compress    

I don't see any compression when it rotates.
The logs were also much bigger when I first ran it and it didn't split it up in files of max 10M size, it just moved the old file to .1

I got an error no such files or directories

executing: /bin/bash -c /usr/bin/logrotate.d/update-logrotate.sh; /usr/sbin/logrotate --state=/logrotate-status/logrotate.status /usr/bin/logrotate.d/logrotate.conf
find: "/var/log/docker: No such file or directory
find: /var/log/nginx": No such file or directory

├── docker-compose.yml
└── logs
    ├── file.log
    └── nginx
        ├── access.log
        └── error.log

This is my docker-compose.yaml setup

---
version: '2.4'
services:
  ssl:
    image: nginx:latest
    ports:
      - 2020:80
    volumes:
      - ./logs/nginx:/var/log/nginx
  logrotate:
    image: blacklabelops/logrotate:1.3
    environment:
      - LOGS_DIRECTORIES="/var/log/docker /var/log/nginx"
      - LOGROTATE_INTERVAL=hourly
      - LOGROTATE_COMPRESSION=compress
      - LOGROTATE_COPIES=30
      - TZ=Asia/Singapore
      - LOGROTATE_CRONSCHEDULE=* * * * * *
    volumes:
      - ./logs:/var/log/docker
      - ./logs/nginx:/var/log/nginx

Logrotate a subfolder folder inside a volume

Any way to log rotate a subfolder of a volume?
I've tried:

volumes:
  - /var/lib/docker/volumes/wp_docker_litespeed_lsws_sites/_data/localhost/wp_logs:/var/log/wp

and

LOGS_DIRECTORIES: "/var/lib/docker/containers /var/log/docker /var/lib/docker/volumes /var/log/wp"

Healthcheck?

Hi is there some way to do a healthcheck when using blacklabelops/logrotate?

Default logrotate_croninterval invalid

The default logrotate_croninterval="1 0 0 0 * *" (at

logrotate_croninterval="1 0 0 0 * *"
) seems to be invalid. This value is used when LOGROTATE_CRONSCHEDULE is not set. It results in no invocations of logrotate and the following error message:

2016/11/21 16:40:23 Beginning of range (0) below minimum (1): 0

The 4th (day of month) can not be 0, it must be in range 1-31.

I am unsure what the intended value is, but I think it must be at least hourly looking at the lowest possible logrotate interval. If this is the case a cron interval of 0 0 * * * * would work. (every hour at 0 minutes and 0 seconds).

I am working around this by providing a valid LOGROTATE_CRONSCHEDULE as environment var.

Pre/post scripts

How would one go about sending a signal from one container process to another container process?

For nginx, the worker needs to be gracefully restarted to remove the file handle on the log files via something like:

postrotate
  [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript

But, as a sidecar, how would you do this without exposing the docker control socket?

Not to able run in K8s w/o root user

Hi,
I am trying to deploy log rotate in the K8s cluster as a sidecar container but getting permission denied error.
touch: /usr/bin/logrotate.d/logrotate.conf: Permission denied

Is it possible to run logrotate w/o root privileges?

Add support for logging files without extension?

I would like to setup this cool container to rotate syslog file, but it looks like it cannot be done with the envs provided, since the code assume you have files with extension, or am I missing something?

Question: will logs keep expiring when a container dies

Hi, one quick question, if a container dies/recreated with a new container ID, and the old one is deleted, e.g. by K8s, will the rotated logs expire after the expected date?

I guess not, since the config is updated to new containers. If this is true, is there a way to handle this?

Thanks!

Repository Deprecated

I will stop supporting and implementing Docker images starting in early 2019.

Repositories will be transferred to blacklabelops-legacy and archived for read only purpose.

The following repositories and images are affected:

January 2019

  • blacklabelops/crowd
  • blacklabelops/nginx
  • blacklabelops/bitbucket
  • blacklabelops/java
  • blacklabelops/letsencrypt
  • blacklabelops/postgres

March 2019

  • blacklabelops/baseimages
  • blacklabelops/confluence
  • blacklabelops/jira
  • blacklabelops/volumerize
  • blacklabelops/logrotate

Unknown groups/users don't appear to be rotated

I have many log files present in /var/log/company_name to be rotated on an hourly basis into /var/log/company_name/rotated, keeping the past 24-hours. All logs seem to be rotating except a select few, which grow to gigabytes in size.

Upon inspecting the logrotate logs with docker logs logrotate, it appears that all the logfiles that aren't rotating have the following message printed when processing:

Found new file /var/log/company_name/mysql_error.log, Processing...
File has unknown user or group: , user: UNKNOWN, group: video

However, logfiles that are properly rotated have the following message printed:

Found new file /var/log/company_name/wkhtmltopdf.gunicorn.log, Processing...
Inserting new /var/log/company_name/wkhtmltopdf.gunicorn.log to /usr/bin/logrotate.d/logrotate.conf

Other notes:
User: root
Logrotate version: 1.2
Logrotate hash: sha256:e0d5e50a8716d7859079df4849f9034c56d0cb38ed46ad118b87e41f8a9437d6
Capabilities: dac_override, setgid, setuid
Network: none
Environment:

LOGROTATE_INTERVAL=hourly
LOGS_DIRECTORIES=/var/log/company_name
LOGROTATE_OLDDIR=/var/log/company_name/rotated
LOGROTATE_LOGFILE=/var/log/company_name/logrotate.log
LOGROTATE_COPIES=24
LOGROTATE_COMPRESSION=compress
LOGROTATE_STATUSFILE=/company_name/logrotate_status/logrotate.status
LOGROTATE_PARAMETERS=vf

I also tried enabling all capabilities and the network without any luck.

The error message appear accurate when running an ls -lahS on the log directory. But I don't understand why logrotate won't touch those files or how to force it to work with those files.

LOGROTATE_INTERVAL=hourly rotates on a daily basis

I have the fallowing docker compose that is launched within a docker swarm. The rotation interval is set to hourly, but the logs are rotated daily.

version: '3.3'

services:
  log-roate:
    image: blacklabelops/logrotate
    environment:
      - LOGS_DIRECTORIES=/var/lib/docker/containers
      - LOGROTATE_COPIES=100
      - LOGROTATE_COMPRESSION=compress
      - LOGROTATE_INTERVAL=hourly
      - LOGROTATE_DATEFORMAT=-%Y-%m-%d-%s
    volumes:
      - type: bind
        source: /var/lib/docker/containers
        target: /var/lib/docker/containers
    deploy:
      mode: global

LOGROTATE_MAXAGE does not work

configurations as below:

  • name: LOGS_DIRECTORIES
    value: /var/log/cmcapi
  • name: LOGROTATE_COPIES
    value: "3"
  • name: LOGROTATE_SIZE
    value: 100M
  • name: LOGROTATE_MAXAGE
    value: "2"
  • name: LOGROTATE_CRONSCHEDULE
    value: '0 */1 * * *'

but the LOGROTATE_MAXAGE does not work. there still are 3 days logs.
MicrosoftTeams-image

Cron environment variable not having impact on logrotate

Hello,

I'm trying to use the logrotate docker image. I am overriding the LOGROTATE_CRONSCHEDULE environment variable. However, it is not having an impact on the logrotate command. Can you take a look?

environment:
        - "LOGS_DIRECTORIES=/home/logs"
        - "LOGROTATE_CRONSCHEDULE=* * * * * *"
        - "LOGROTATE_LOGFILE=/tmp/rotate-log"
        - "LGROTATE_PARAMETERS=vf"
        - "LOGROTATE_DATEFORMAT=-%Y-%m-%d-%s"
        - "LOGROTATE_COPIES=5"

Add 'ignore folders' option?

Hi

I'm not sure if this container is abandonware or not, but I just discovered and implemented it, and it seems perfect for me with one small exception.

I have all of my containers set to place all of their logs in a central location on the host (/mnt/e/logs) and then a subdir per container.

In my case, it would be cleaner and more efficient to just mount the top-level dir as the volume mount, and then use an env var to ignore specific dirs (some containers have built in rotate mechanisms that I don't need this container to rotate for them).

Currently, I have to mount something like 20 containers, and also add them each on the single env var line, like this:

LOGS_DIRECTORIES: '/mnt/e/Docker/Logs/authelia /mnt/e/Docker/Logs/mysql /mnt/e/Docker/Logs/something /mnt/e/Docker/Logs/somethingelse' (etc., for another 15 or so more)

Having an env var something like:

LOGS_IGNORE_DIRECTORIES: '/mnt/e/Docker/Logs/ignorethisone /mnt/e/Docker/Logs/ignorethisonetoo'

Would be much nicer, because then I'd just mount the top-level dir, let logrotate recurse through all subdirs, and ignore just like, 3 directories. :)

Specifying files in the options

Thanks for a great project. I have only a small (yet getting bigger) problem:

$ ls -lh
-rwxrw-rw-    1 root     root        1.6K Dec  3 01:14 alternatives.log
drwxrw-rw-    2 root     root        4.0K Dec  3 01:42 apt
drwxr-xr-x    2 root     root        4.0K Nov 19 03:59 docker
-rwxrw-rw-    1 root     root      527.4K Dec  9 05:15 docker.log
-rwxrw-rw-    1 root     root       36.5M Dec  4 00:00 docker.log-20171204.gz
-rwxrw-rw-    1 root     root        1.2M Dec  8 00:00 docker.log-20171208
-rwxrw-rw-    1 root     root       59.4K Dec  3 01:42 dpkg.log
-rw-r--r--    1 root     root         510 Dec  3 01:42 fontconfig.log
-rwxrw-rw-    1 root     root      314.0K Dec  9 05:15 lastlog
-rwxrw-rw-    1 root     root        1.7G Dec  9 05:17 messages
-rwxrw-rw-    1 root     root      663.5M Dec  9 05:17 secure
-rwxrw-rw-    1 root     root        2.3G Dec  9 05:17 syslog

As you can see secure, messages and syslog weren't touched by logrotate. Is it possible for you guys to have an option where we can add LOGS_FILES?

Dockerhub Build Fail

The new image is Alpine Docker 1.9 conform. Dockerhub is still on Docker 1.8 build slaves. This ticket is to remind me to check builds.

Imagelayers also seems to have problems when Dockerhub builds fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.