可以在/etc/systemd/journald.conf上找到全局配置,默认值将为您服务,因此您可以使用默认值.顺便说一句,以下是可用于更改日志记录行为的配置: SystemKeepFree:其他应用程序剩余多少磁盘空间(默认= 15%). SystemMaxuse:最大磁盘空间使用量(默认= 10%). 默认情况下,systemd尽可能保留日志(受上述规则限制),但是,如果您需要基于轮换的配置,则可以使用MaxRetentionSec.同样,您不必担心systemd的磁盘使用情况,只需使用默认配置即可.I have a service in **/etc/systemd/sysem/horses.service**[Unit]Description=Description for sample script goes hereAfter=rc-local.service[Service]Type=simpleExecStart=/opt/horses/startSanic2.shTimeoutStartSec=0Environment="REDIS_HOST=192.168.150.220"Environment="REDIS_PORT=6379"[Install]WantedBy=default.targetIt runs the shell script with this code:#!/bin/bashgunicorn horses.server:app --bind 0.0.0.0:9000 --worker-class sanic.worker.GunicornWorker --reloadI succesfully run it and I can see the logs of the service are being written and can be read from:journalctl -u horses.serviceif I run that command - I can see all events which that horses.service logs.I do not have any experience with logs for systemd services.My very big concern is that because this service will be running all the time - is it possible for example to set to keep the information (logs) in journalctl -u horses.service only for example for last 10 days, or to define some round logging or whatever method is suggested in order to be sure that my logs will not be full because I do want to end with my whole disk (partition) full.Please suggest me how I can limit the logs.Thank you in advance!!!!!!! 解决方案 What you see by running journalctl -u is the output of your app to console (or errors) which systemd take care of them for you.The global configurations can be find at /etc/systemd/journald.conf and default values will serve your concern, so you are Ok with default values.Btw, here are configurations you can use to alter the logging behavior:SystemKeepFree: How much disk space leave for other applications(default = 15%). SystemMaxuse: Maximum disk space usage (default = 10%).By default systemd keep logs as long as it can (restricted by above rules) however if you need a rotation based configuration you can use MaxRetentionSec.And again, you don't need to worry about disk usage by systemd, just use default configurations. 这篇关于限制"journalctl服务"的日志在systemd中-Centos 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-17 03:35