- Plesk for Linux
How to force Plesk to rotate logs more often?
By default Plesk rotates logs once per day (during the Daily task).
To make log rotation more often, log rotation task can be scheduled in addition to the Daily one:
Note: This modification might result in performance degradation if the server has a lot of domains: statistics are analyzed alongside with the log rotation.
Navigate to Tools & Settings > Scheduled Tasks.
Click on Add Task.
Add the following text to the Command field:
To rotate logs for all domains:
CONFIG_TEXT: /usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/DailyMaintainance/script.php -f ExecuteStatistics
To rotate logs for a single domain:
CONFIG_TEXT: /usr/local/psa/admin/sbin/statistics --calculate-one --domain-name=example.com
Set to run task Hourly and click on Ok.
This solution is what I'm looking for to rotate several customers with quickly growing logs, where daily is not enough. However, I'm concerned this new scheduled task might conflict with the normal daily task. If I add this new task, as in the example, above, I'm concerned that when the normal daily task runs, this new task might also run at the same time, or might still be running, when the daily task runs.
Would it be helpful to schedule this new task to run on a schedule less likely to happen at the same time the normal daily task runs?
Hello @Bob B,
You concern is totally understandable and valid, that is why note added on the top of the article about the possible server performance influence. Let me clarify:
These tasks will not interrupt each other, but will run simultaneously spawning many processes and thus overloading the server. It may happen only if amount of the domains is quite big and/or there are many files inside these domains' virtual directories on the server. Thus, before applying this resolution, you may estimate it either by just taking approximate time period judging by the domains' amount and disk space, or, as a possible way, you may want to run this command in the terminal:
# /usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/DailyMaintainance/script.php -f ExecuteStatistics
Check how much time will it take to execute and set appropriate time period for the task.
You may also want to run this command in the screen if amount of domains is quite big and additionally you may enable Plesk debug mode, so this command will give you prompt output as well.
Thank you. Great information. Quick followup question... If there are only a few end users whose logs grow big quickly, and need more frequent rotation, would it be a better idea to use the "/usr/local/psa/admin/sbin/statistics --calculate-one --domain-name=example.com" command, via hourly Scheduled Task (cron), for the affected domains, instead of "ExecuteStatistics" for all domains, as described in article (https://support.plesk.com/hc/en-us/articles/213936305-How-to-recalculate-statistics-for-a-particular-domain-in-Plesk-)?
Indeed, that will be correct as well.
Thank you for the suggestion. I added it to the article.
Please sign in to leave a comment.