I have the following cronjob which pipes docker (apache) logs into a file:
* * * * * flock -n /srv/www/htdocs/scripts/pipe.lock /srv/www/htdocs/scripts/pipe_docker_logs.sh
the pipe_docker_logs.sh simply does a:
tail -f `docker inspect --format='{{.LogPath}}' docker_apache` >& /var/log/apache2/docker_apache_access.log &
The file writen by this tail background process is rotated by logrotate.d
If the file is rotated, the tail process stops writing to the newly created file. Killing the tail process and waiting till cron restarts it, starts writing to the log file again.
Now I guess I would need some kill or restart command if the log is rotated.
Maybe cron is the wrong place to do this and logrotate.d should do this?
Any hints?
I know about ELK and fluent ... but this is just one container and would be overkill.