Systemd基础篇:4:对服务启动出现的问题进行debug的方法

本文介绍了如何解决Systemd服务启动问题,特别是当workingdirectory不存在时,常规方法无法提供足够信息的情况。通过调整system.conf设置LogLevel为debug,重启系统,并在启动服务后使用status或journalctl查看详细日志,来辅助诊断问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
Systemd被诟病的很多的点之一就是出现问题之后很难确认原因,其实在很早的时候systemd就提供了debug的方法,这篇文章介绍常用的一种方式,并结合一个常见的很容易忽视的问题来进行说明。

场景

workingdirectory事前不存在,但是status提示信息过少,journalctl没有有益信息提示,详细可参看下述文章:

设定方式

使用如下方式可以在CentOS7上得到验证可以对服务启动进行debug,与其说debug,更准确地说是打出相关的日志信息以进行辅助。

Step 1: 设定system.conf

对象文件:/etc/systemd/system.conf

  • 修改内容:设定LogLevel

LogLevel=debug

  • 设定例
[root@liumiaocn systemd]# cat system.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See systemd-system.conf(5) for details.

[Manager]
LogLevel=debug
#LogLevel=info
#LogTarget=journal-or-kmsg
#LogColor=yes
#LogLocation=no
#DumpCore=yes
#CrashShell=no
#ShowStatus=yes
#CrashChVT=1
#CtrlAltDelBurstAction=reboot-force
#CPUAffinity=1 2
#JoinControllers=cpu,cpuacct net_cls,net_prio
#RuntimeWatchdogSec=0
#ShutdownWatchdogSec=10min
#CapabilityBoundingSet=
#SystemCallArchite
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值