6

I have a service that runs every 30 seconds. The systemd timer file for this service is as below:

~# cat /etc/systemd/system/speed_check.timer
[Unit]
Description="Check device speed"

[Timer]
OnBootSec=1
OnUnitActiveSec=30

[Install]
WantedBy=multi-user.target

The service file simply calls a python script:

# cat /etc/systemd/system/speed_check.service 
[Unit]
Description=Check device speed

[Service]
Type=simple
ExecStart=/usr/bin/check-speed

Every 30 seconds, when systemd starts the service, it prints two logs:

Jan  8 17:54:23 localhost systemd[1]: Starting Check device speed...
Jan  8 17:54:23 localhost systemd[1]: Started Check device speed.

Is there a way to suppress these messages? They are filling up my syslog!

thanks

2

There are several possibilites. You should configure the file /etc/systemd/journald.conf. Two relevant options (from the man page) are:

RateLimitInterval=, RateLimitBurst=

 Configures the rate limiting that is applied to all messages generated on the system. If, in the time interval
       defined by RateLimitInterval=, more messages than specified in RateLimitBurst= are logged by a service, all
       further messages within the interval are dropped until the interval is over. A message about the number of
       dropped messages is generated. This rate limiting is applied per-service, so that two services which log do not
       interfere with each other's limits. Defaults to 1000 messages in 30s. The time specification for
       RateLimitInterval= may be specified in the following units: "s", "min", "h", "ms", "us". To turn off any kind of
       rate limiting, set either value to 0.

and

Storage=

      Controls where to store journal data. One of "volatile", "persistent", "auto" and "none". If "volatile", journal
       log data will be stored only in memory, i.e. below the /run/log/journal hierarchy (which is created if needed).
       If "persistent", data will be stored preferably on disk, i.e. below the /var/log/journal hierarchy (which is
       created if needed), with a fallback to /run/log/journal (which is created if needed), during early boot and if
       the disk is not writable.  "auto" is similar to "persistent" but the directory /var/log/journal is not created if
       needed, so that its existence controls where log data goes.  "none" turns off all storage, all log data received
       will be dropped. Forwarding to other targets, such as the console, the kernel log buffer or a syslog daemon will
       still work however. Defaults to "auto".

Thus you can turn off all syslogs by means of Storage=none, but this seems excessive and unwise. Limiting the rate (the first option= is much wiser; the default is 1000 messages per 30s, which is way above what you wish, and explains why you are having so much output, unchecked.

Or, you may use one of these options,

   SystemMaxUse=, SystemKeepFree=, SystemMaxFileSize=, RuntimeMaxUse=, RuntimeKeepFree=, RuntimeMaxFileSize=

to control the size of journal files stored. You can pair these options with one of these,

MaxFileSec=

      The maximum time to store entries in a single journal file before rotating to the next one

MaxRetentionSec=

      The maximum time to store journal entries.

to retain all syslog messages, but for a shorter time.

Lastly, you may wish to use:

MaxLevelStore=, MaxLevelSyslog=, MaxLevelKMsg=, MaxLevelConsole=, MaxLevelWall=

      Controls the maximum log level of messages that are stored on disk, forwarded to syslog, kmsg, the console or
       wall (if that is enabled, see above). As argument, takes one of "emerg", "alert", "crit", "err", "warning",
       "notice", "info", "debug" or integer values in the range of 0..7 (corresponding to the same levels). Messages
       equal or below the log level specified are stored/forwarded, messages above are dropped. Defaults to "debug" for
       MaxLevelStore= and MaxLevelSyslog=, to ensure that the all messages are written to disk and forwarded to syslog.
       Defaults to "notice" for MaxLevelKMsg=, "info" for MaxLevelConsole= and "emerg" for MaxLevelWall=.

to forgo less important messages, and retain only critical ones.

  • Thanks very very much for references to the man pages. – linuxfan Jan 8 '15 at 18:54
  • 1
    The options RateLimitInterval and RateLimitBurst seem to be global. Can they be applied to an individual service? The man page doesn't say much. – linuxfan Jan 8 '15 at 21:00
  • @linuxfan Not that I know – MariusMatutiae Jan 8 '15 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.