在Ubuntu中,可以使用systemd来管理系统服务,下面是一些常用的管理服务的方法和示例:
1、查看已安装的服务列表:
“`
systemctl listunits type=service
“`
2、启动一个服务:
“`
systemctl start service_name
“`
service_name
是要启动的服务的名称。
3、停止一个服务:
“`
systemctl stop service_name
“`
4、重启一个服务:
“`
systemctl restart service_name
“`
5、设置开机自启一个服务:
“`
systemctl enable service_name
“`
这将使得该服务在系统启动时自动运行。
6、取消开机自启一个服务:
“`
systemctl disable service_name
“`
这将使得该服务在系统启动时不会自动运行。
7、查看服务的详细信息:
“`
systemctl status service_name
“`
这将显示有关服务的当前状态和其他详细信息。
8、设置服务为开机不自启:
“`
systemctl isenabled service_name
“`
如果输出为"disabled",则表示该服务未设置为开机自启。
9、设置服务的优先级:
“`
systemctl setproperty service_name "StartLimitIntervalSec=10" "StartLimitBurst=5" "RestartSec=10" "RestartUSec=1000000" "CPUQuota=50%" "MemoryLimit=infinity" "TasksMax=infinity" "OOMScoreAdjust=1000" "Nice=19" "RuntimeMaxSec=infinity" "TimeoutStopSec=infinity" "SendSIGKILL=no" "SendSIGHUP=yes" "WatchdogSec=0" "WatchdogTimestampMonotonic=yes" "WatchdogTimestampBoottime=yes" "WatchdogType=poweroff" "RestartPreventExitStatus=SIGINT SIGTERM" "RestartForceExitStatus=SIGINT SIGTERM SIGQUIT SIGILL SIGABRT SIGSEGV" "MaskedEvents=INT,TERM,QUIT,ILL,ABRT,SEGV,SYS" "UnitFileState=enabled" "AssertPath=/usr/local/bin/assert.sh" "AssertScript=/usr/local/bin/assert.sh %p" "AssertReloadSec=30" "AssertType=process" "AssertCategories=gui,network,io,console,filesystem,kernel,mail,authpriv,systemdlogind,user,timer,rtc,random,plymouth,bluetooth,rfkill,lightdm,x11,keyboard,touchpad,powerdev,mountall,automount,avahidaemon,colord,cups,dbusbroker,dmesg,gdm3,geoclue2,hibernate,iiosensorproxy,irqbalance,kexectools,libutempter,lmsensors,mdadm,microcode_checker,netcfg,nvidiapersistenced,open网络加密层,ostreecommitqueue,plymouthquitwaiting.service,pulseaudio,rcugpio,rcupowernowk8s.service,rcurtcgpio,restorecond,rtkitdaemon,rtkitplugtests,sandboxd,speechdispatcher,systemdaskpasswordwall.path,systemdbacklight@backlight:acpi_video0.service,systemdbootchart.service,systemdfsckd.service,systemdhostnamed.service,systemdjournald.service,systemdjournaldstatic.service,systemdlogind.service,systemdnetworkd.service,systemdnspawn.service,systemdrandomseed.service,systemdreadaheadcollect.service,systemdremountfs.service,systemdrfkill.service,systemdscreenlocker.service,systemdsessiond.service,systemdsetvtrgb.service,systemdshutdownd.service,systemdsockets.service,systemdsuspend.service,systemdtimesyncd.service,systemdudevd.service,systemdudevtrigger.service,systemdupdateutmp.service,systemdusersessions.service,systemduserdump.service,systemdvconsole.service" "Slice=" "CPUQuotaGroup=" "CPUQuotaGroupMembers=12%" "CPUQuotaPeriodUSec=1min" "CPUQuotaUser=root" "CPUShares=512" "TasksMax=infinity" "OOMScoreAdjust=1000" "Nice=19" "RuntimeMaxSec=infinity" "TimeoutStopSec=infinity" "SendSIGKILL=no" "SendSIGHUP=yes" "WatchdogSec=0" "WatchdogTimestampMonotonic=yes" "WatchdogTimestampBoottime=yes" "WatchdogType=poweroff" "RestartPreventExitStatus=SIGINT SIGTERM" "RestartForceExitStatus=SIGINT SIGTERM SIGQUIT SIGILL SIGABRT SIGSEGV" "MaskedEvents=INT,TERM,QUIT,ILL,ABRT,SEGV,SYS" "UnitFileState=enabled" "AssertPath=/usr/local/bin/assert.sh" "AssertScript=/usr/local/bin/assert.sh %p" "AssertReloadSec=30" "AssertType=process" "AssertCategories=gui network io console filesystem kernel mail authpriv systemdlogind user timer rtc random plymouth bluetooth rfkill lightdm x11 keyboard touchpad powerdev mountall automount avahidaemon colord cups dbusbroker dmesg gdm3 geoclue2 hibernate iiosensorproxy irqbalance kexectools libutempter lmsensors mdadm microcode_checker netcfg nvidiapersistenced open网络加密层 ostreecommitqueue plymouthquitwaiting.service pulseaudio rcugpio rcupowernowk8s.service rcurtcgpio restorecond rtkkit daemon rtkkit plugtests sandboxd speech dispatcher systemd ask password wall path systemd backlight acpi video0 service systemd bootchart service systemd fsckd service systemd host name d service systemd journal d static service systemd login d service systemd network d service systemd nspawn service systemd random seed service systemd read ahead collect service systemd remount fs service systemd rfkill service systemd screen locker service systemd session d service systemd set vtrgb service systemd shutdown d service systemd sockets service systemded process with PID <PID> and UTS namespace <UTSNAME>."
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/604421.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复