300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > CentOS linux7 设置开机启动服务

CentOS linux7 设置开机启动服务

时间:2022-06-10 16:58:26

相关推荐

CentOS linux7 设置开机启动服务

常用命令

描述旧命令 新命令

使服务自动启动chkconfig --level 3 http onsystemctl enable 服务名.service systemctl enable httpd.service

使服务不自动启动 chkconfig --level 3httpd offsystemctl disable 服务名.sevice

查看服务章台 service httpd status systemctl status httpd.service systemctl is-active httpd.service

查看所有已启动的服务 chkconfig --listsystemctl list-units --type=service

启动服务 service httpd start systemctl start httpd.service

停止服务 service httpd stop systemctl stop httpd.service

重启服务 service httpd restart systemctl restart httpd.service

1 、把服务设置成系统服务

a、找到系统服务目录、systemd/system(假如有多个此目录,可通过目录下是否有.service文件来判断是否)

b、新建文件,假如需要把tomcat加入到服务中,则新建tomcat.service #touch tomcat.service

c、文件中输入必要信息,vi tomcat.service,如下:

[Unit]

Description=nginx #描述

After=network.target #服务类别

[Service]

Type=forking #运行形式

ExecStart=/xx/xx start #注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

ExecReload=/xx/xx restart注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

ExecStop=/xx/xx stop注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

PrivateTmp=true #表示给服务分配独立的临时空间

[Install]

WantedBy=multi-user.target #服务安装的相关设置,可设置为多用户

d、设置后保存

e、设置成开机自启动(systemctlenabletomcat.service)后每次开启此服务自动启动,无需人工启动

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。