Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logrotate instead of custom script #50

Open
andsens opened this issue Jul 18, 2012 · 4 comments
Open

Use logrotate instead of custom script #50

andsens opened this issue Jul 18, 2012 · 4 comments
Assignees

Comments

@andsens
Copy link

andsens commented Jul 18, 2012

Why don't you use logrotate for rolling over logs?
It's directly built into debian and supports restarting services and loads of other stuff.
You don't even need a cronjob, single file in /etc/logrotate.d and you're done.
It has loads of config options.

@ghost ghost assigned marcuswhybrow Jul 18, 2012
@marcuswhybrow
Copy link

Looks interesting. I am looking for something to provide purging of all logs, as well as world and server backups. This might be a partial or total solution.

@marcuswhybrow
Copy link

From the man page it looks as though it would be useful for rotating server.log, but not purging old backups.

Looks like it would be a better tool than the wheel reinvention I have in place at the moment.

@andsens
Copy link
Author

andsens commented Jul 18, 2012

rotate count
             Log  files  are  rotated  <count>  times before being removed or mailed to the address specified in a mail
             directive. If count is 0, old versions are removed rather then rotated.

@morbeo
Copy link
Contributor

morbeo commented Feb 10, 2013

I've played around with a config file which you can put in /etc/logrotate.d/ . You can test configs with logrotate -d -f

# Sample wildcard
/opt/msm/servers/*/server.log {
# Running with cron.daily time
daily 
olddir /opt/msm/archives/logs/
# Keeps a fortnight
rotate 14 
# Don't rotate empty logs
notifempty 
}

The issue with this is old logs are located in separate folders for each server in /opt/msm/archive/logs/ which cannot be interpreted to the olddir directive. If a unified folder is used for all the servers there is a conflict of names, because all the logs are named server.log. What I think could work is something like this where each server is appended after its created with MSM

# Main config file to which each server is appended
daily
rotate 14
notifempty

Sample append in server_create() for example

echo -e "$SETTINGS_SERVER_STORAGE_PATH/$1/server.log { \n olddir $LOG_ARCHIVE_PATH/$1/ \n } " >> /etc/logrotate.d/msm

This will most likely work, but will be difficult to manage if a server is removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants