5초마다 .service를 실행하는 시스템 .timer가 있습니다. 서비스 자체는 stout 또는 stderr에 아무 것도 출력하지 않습니다. 그런데 확인해 보니 journalctl -u <service_name>
정말 많이 보이더군요.
systemd[1]: Started ...
systemd[1]: <sevice_name>: Succeeded.
특정 서비스의 출력만 억제하는 방법이 있나요? 감사해요.
UPD: 5m마다 추가 정보 및 변경 사항
# cat munin-cron.timer
[Unit]
Description=Survey monitored computers every five minutes
[Timer]
OnCalendar=*-*-* *:00/5:00
[Install]
WantedBy=multi-user.target
# cat munin-cron.service
[Unit]
Description=Survey monitored computers
After=network.target
[Service]
Type=exec
User=munin
LogLevelMax=alert
SyslogLevel=2
ExecStart=/usr/bin/munin-cron
# systemctl show munin-cron.service
Type=exec
Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
TimeoutAbortUSec=1min 30s
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=0
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
UID=[not set]
GID=[not set]
NRestarts=0
OOMPolicy=stop
ExecMainStartTimestamp=Mon 2019-10-21 06:30:00 CEST
ExecMainStartTimestampMonotonic=193534630899
ExecMainExitTimestamp=Mon 2019-10-21 06:30:12 CEST
ExecMainExitTimestampMonotonic=193546001811
ExecMainPID=68208
ExecMainCode=1
ExecMainStatus=0
ExecStart={ path=/usr/bin/munin-cron ; argv[]=/usr/bin/munin-cron ; ignore_errors=no ; start_time=[Mon 2019-10-21 06:30:00 CEST] ; stop_time=[Mon 2019-10-21 06:30:12 CEST] ; pid=68208 ; code=exited ; status=0 }
ExecStartEx={ path=/usr/bin/munin-cron ; argv[]=/usr/bin/munin-cron ; flags= ; start_time=[Mon 2019-10-21 06:30:00 CEST] ; stop_time=[Mon 2019-10-21 06:30:12 CEST] ; pid=68208 ; code=exited ; status=0 }
Slice=system.slice
MemoryCurrent=[not set]
CPUUsageNSec=[not set]
TasksCurrent=[not set]
IPIngressBytes=[no data]
IPIngressPackets=[no data]
IPEgressBytes=[no data]
IPEgressPackets=[no data]
IOReadBytes=18446744073709551615
IOReadOperations=18446744073709551615
IOWriteBytes=18446744073709551615
IOWriteOperations=18446744073709551615
Delegate=no
CPUAccounting=no
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
CPUQuotaPeriodUSec=infinity
IOAccounting=no
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=no
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=yes
DefaultMemoryLow=0
DefaultMemoryMin=0
MemoryMin=0
MemoryLow=0
MemoryHigh=infinity
MemoryMax=infinity
MemorySwapMax=infinity
MemoryLimit=infinity
DevicePolicy=auto
TasksAccounting=yes
TasksMax=infinity
IPAccounting=no
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=infinity
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=524288
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=1857
LimitNPROCSoft=1857
LimitMEMLOCK=65536
LimitMEMLOCKSoft=65536
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=1857
LimitSIGPENDINGSoft=1857
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=0
LimitRTPRIOSoft=0
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
OOMScoreAdjust=0
Nice=0
IOSchedulingClass=0
IOSchedulingPriority=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
CPUAffinity=
NUMAPolicy=n/a
NUMAMask=
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardInputData=
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=26
SyslogLevelPrefix=yes
SyslogLevel=2
SyslogFacility=3
LogLevelMax=1
LogRateLimitIntervalUSec=0
LogRateLimitBurst=0
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend cap_audit_read
AmbientCapabilities=
User=munin
DynamicUser=no
RemoveIPC=no
MountFlags=
PrivateTmp=no
PrivateDevices=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
PrivateMounts=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=0
LockPersonality=no
RuntimeDirectoryPreserve=no
RuntimeDirectoryMode=0755
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
ConfigurationDirectoryMode=0755
TimeoutCleanUSec=infinity
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictSUIDSGID=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
ProtectHostname=no
KillMode=control-group
KillSignal=15
FinalKillSignal=9
SendSIGKILL=yes
SendSIGHUP=no
WatchdogSignal=6
Id=munin-cron.service
Names=munin-cron.service
Requires=sysinit.target system.slice
Conflicts=shutdown.target
Before=shutdown.target
After=sysinit.target network.target munin-cron.timer systemd-journald.socket basic.target system.slice
TriggeredBy=munin-cron.timer
Description=Survey monitored computers
LoadState=loaded
ActiveState=inactive
SubState=dead
FragmentPath=/etc/systemd/system/munin-cron.service
UnitFileState=static
UnitFilePreset=disabled
StateChangeTimestamp=Mon 2019-10-21 06:30:12 CEST
StateChangeTimestampMonotonic=193546002012
InactiveExitTimestamp=Mon 2019-10-21 06:30:00 CEST
InactiveExitTimestampMonotonic=193534631573
ActiveEnterTimestamp=Mon 2019-10-21 06:30:00 CEST
ActiveEnterTimestampMonotonic=193534639294
ActiveExitTimestamp=Mon 2019-10-21 06:30:12 CEST
ActiveExitTimestampMonotonic=193546002012
InactiveEnterTimestamp=Mon 2019-10-21 06:30:12 CEST
InactiveEnterTimestampMonotonic=193546002012
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Mon 2019-10-21 06:30:00 CEST
ConditionTimestampMonotonic=193534628264
AssertTimestamp=Mon 2019-10-21 06:30:00 CEST
AssertTimestampMonotonic=193534628265
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=f16620fc799644929a09903ef54e1415
CollectMode=inactive
# journalctl -u munin-cron.service
Oct 21 06:25:00 hostname systemd[1]: Starting Survey monitored computers...
Oct 21 06:25:00 hostname systemd[1]: Started Survey monitored computers.
Oct 21 06:25:11 hostname systemd[1]: munin-cron.service: Succeeded.
Oct 21 06:30:00 hostname systemd[1]: Starting Survey monitored computers...
Oct 21 06:30:00 hostname systemd[1]: Started Survey monitored computers.
Oct 21 06:30:12 hostname systemd[1]: munin-cron.service: Succeeded.
Oct 21 06:35:00 hostname systemd[1]: Starting Survey monitored computers...
Oct 21 06:35:00 hostname systemd[1]: Started Survey monitored computers.
Oct 21 06:35:11 hostname systemd[1]: munin-cron.service: Succeeded.
답변1
.service
중요한 이벤트만 기록되는 수준으로 로그 수준을 낮추면 이 작업을 빠르게 수행할 수 있습니다 .
허용되는 로그 수준은 다음과 같습니다.신흥, 경고, 중요, 오류, 경고, 알림, 정보, 디버그
.service
구성 파일 에 다음을 추가하여
LogLevelMax=alert
그러나 .service
설정 자체가 5초마다 다시 시작되어서는 안 되기 .timer
때문에 매우 비생산적인 것 같습니다 . 서비스가 시작된 후 스크립트 자체가 반복적인 작업을 수행하지 않도록 선택하는 주요 이유는 무엇입니까? 스스로 발견했듯이 시스템은 새 시스템을 시작/추가/다시 로드할 때 많은 것을 기록하고 추가합니다..service
.service