sevice、systemctl、lauchctl(mac)开机自启动指令设置

以设置httpd开机自启动为例

指令
service指令
systemctl 指令
launchctl指令(Mac)
编写启动脚本目录
vi /etc/init.d/httpd
vi /usr/lib/systemd/system/httpd.service
vi /etc/systemd/system/httpd.service
~/Library/LaunchAgents 由用户自己定义的任务项
/Library/LaunchAgents 由管理员为用户定义的任务项
/Library/LaunchDaemons 由管理员定义的守护进程任务项
/System/Library/LaunchAgents 由Mac OS X为用户定义的任务项
/System/Library/LaunchDaemons 由Mac OS X定义的守护进程任务项
脚本赋权
chmod +x /etc/init.d/httpd
chmod +x /usr/lib/systemd/system/httpd.service
使某服务自动启动
Centos:
chkconfig -–level 3 httpd on
chkconfig --add  httpd
Ubuntu:
update-rc .d httpd  defaults
systemctl enable httpd.service
launchctl load -w com.httpd.plist
使某服务不自动启动
Centos:
chkconfig –-level 3 httpd off
chkconfig —del  httpd
Ubuntu:
update-rc.d -f httpd  remove
systemctl disable httpd.service
launchctl unload -w com.httpd.plist
检查服务状态
service httpd status
systemctl status httpd.service
显示所有已启动的服务
chkconfig –-list
systemctl  list-units --type  service
launchctl list | grep 'com.httpd'
启动某服务
service httpd start
systemctl start httpd.service
launchctl start  com.httpd.plist
停止某服务
service httpd stop
systemctl stop httpd.service
launchctl stop  com.httpd.plist
重启某服务
service httpd restart
systemctl restart httpd.service
launchctl restart  com.httpd.plist
重载某服务
systemctl reload httpd.service
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值