OS X进程管理之launchctl
如果 Mac 无法完成启动,请尝试安全模式
如果 Mac 无法开机应如何处理
/System/Library/StartupItems/
DEPRECATED AND REMOVED FUNCTIONALITY
launchctl no longer has an interactive mode, nor does it accept commands from stdin.
The /etc/launchd.conf file is no longer consulted for subcommands to run during early
boot time; this functionality was removed for security considerations. While it was
documented that $HOME/.launchd.conf would be consulted prior to setting up a user's
session, this functionality was never implemented.
launchd no longer uses Unix domain sockets for communication, so the LAUNCHD_SOCKET
environment variable is no longer relevant and is not set.
launchd no longer loads configuration files from the network
FILES
~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System wide daemons provided by the administrator.
/System/Library/LaunchAgents OS X Per-user agents.
/System/Library/LaunchDaemons OS X System wide daemons.
插曲--Mac Pro无法启动
本来想禁止apache开机自启动
launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
结果太大意,没想到手快了一步,命令敲成了
launchctl unload -w /System/Library/LaunchDaemons/
我的个乖乖,突然触摸板,键盘全部失灵,有点慌了,怎么回事儿,还好有点linux基础,看了下命令,把系统的很多Daemons直接停掉并去除了开机启动了,重启后直接卡死在苹果LOGO下,进度好容易走完了,却看不能美美的桌面,完了。真的是没法加载相关Daemon从而加载硬件驱动,系统无法正常启动。
问了下度娘,有说重新加载SMC的,详风苹果官方文档https://support.apple.com/zh-cn/HT201295
试了下,没效果不说,反而风扇狂转不止,更加担心了,难道要重装,oh, my god
又百度了下,看了下无法启动的基本排查思路和顺序,理了理头绪,既然是不小心去掉了开机启动项,还原回去就可以了,于是
A方案(失败)
进Recovery模式,将unload掉的全部加入到开机启动项后重启
chroot /Volumes/Macintosh HD
cp -a System/Library/LaunchDaemons/* Library/StartupItems/
Note that allowing non-root write access to the
/System/Library/LaunchDaemons directory WILL render your system unbootable.
-w Overrides the Disabled key and sets it to false or true for the
load and unload subcommands respectively. In previous versions,
this option would modify the configuration file. Now the state of
the Disabled key is stored elsewhere on- disk in a location that
may not be directly manipulated by any process other than launchd.
jlive@MacBook-Pro:~ $su -
Password:
MacBook-Pro:~ root# ls /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 87 1 0 11:18PM ?? 0:01.56 /usr/sbin/httpd -D FOREGROUND
70 246 87 0 11:18PM ?? 0:00.03 /usr/sbin/httpd -D FOREGROUND
0 3971 3964 0 3:20PM ttys000 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl stop org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 3988 3964 0 3:20PM ttys000 0:00.00 grep httpd
2.daemon start
MacBook-Pro:~ root# launchctl start org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4000 1 0 3:23PM ?? 0:00.15 /usr/sbin/httpd -D FOREGROUND
70 4001 4000 0 3:23PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
3.daemon list
MacBook-Pro:~ root# launchctl list|grep apache
4035 0 org.apache.httpd
0 4003 3964 0 3:23PM ttys000 0:00.00 grep httpd
说明:load|unload并不一定会start|stop相关服务,它只是在start或stop前载入相关配置环境
4.unload plist
MacBook-Pro:~ root# launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4237 4221 0 4:01PM ttys001 0:00.00 grep httpd
4.load plist
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4241 1 0 4:01PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4243 4241 0 4:01PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4245 4221 0 4:01PM ttys001 0:00.00 grep httpd
5.print service-target
MacBook-Pro:~ root# launchctl print system/org.apache.httpd|head
org.apache.httpd = {
active count = 1
path = /System/Library/LaunchDaemons/org.apache.httpd.plist
state = running
program = /usr/sbin/httpd-wrapper
arguments = {
/usr/sbin/httpd-wrapper
-D
FOREGROUND
6.kill service-target
MacBook-Pro:~ root# ps -ef|grep httpd
0 4417 1 0 4:21PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4423 4417 0 4:21PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4429 4221 0 4:21PM ttys001 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl kill SIGKILL system/org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4431 1 0 4:21PM ?? 0:00.15 /usr/sbin/httpd -D FOREGROUND
70 4432 4431 0 4:21PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4434 4221 0 4:21PM ttys001 0:00.00 grep httpd
7.disable service-target
MacBook-Pro:~ root# launchctl disable system/org.apache.httpd
MacBook-Pro:~ root# ps -ef|grep httpd
0 4451 4221 0 4:24PM ttys001 0:00.00 grep httpd
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist: Service is disabled
8.enable service-target
MacBook-Pro:~ root# launchctl enable system/org.apache.httpd
MacBook-Pro:~ root# launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist
MacBook-Pro:~ root# ps -ef|grep httpd
0 4458 1 0 4:25PM ?? 0:00.16 /usr/sbin/httpd -D FOREGROUND
70 4459 4458 0 4:25PM ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
0 4461 4221 0 4:25PM ttys001 0:00.00 grep httpd
转载于:https://www.cnblogs.com/lixuebin/p/10814156.html
OS X进程管理之launchctl相关推荐
- [OS复习]进程管理2
问题:多个进程竞争内存资源 1.解决方法 方案一:采用交换技术,换出一部分进程到外存,以腾出内存空间 方案二:采用虚拟存储技术,每个进程只能装入一部分程序和数据(存储管理部分) 2.对换技术(交换技术 ...
- python中的os abort_Python::OS 模块 -- 进程管理
这里我们介绍os模块中的进程管理相关的操作. os模块提供给了我们访问操作系统功能的接口,我们可以通过os模块提供给我们的进程管理接口,编写多进程程序,这对编写高效.并发的程序提供了方便. 下面是一个 ...
- python os模块进程管理
2019独角兽企业重金招聘Python工程师标准>>> 有两种方式来实现并发性,一种方式是让每个"任务"或"进程"在单独的内在空间中工作,每个 ...
- [OS复习]进程管理5
线程 1.多线程 操作系统中引入进程的目的: 为了描述和实现多个程序的并发执行,以改善资源利用率及提高系统的吞吐量. 操作系统引入线程的目的: 这是为了减少程序并发执行时系统所付出的额外开销(减少管理 ...
- [OS复习]进程管理4
进程调度算法(Short-Term) 1.先来先服务(FCFS) 该方法按照进程到达的先后顺序排队,每次调度队首的进程(就像超市中购物付款一样). FCFS算法属于非剥夺调度方式,实现简单,看似公平. ...
- Python之OS模块进程管理介绍--os.fork()
转自:http://davidbj.blog.51cto.com/4159484/1240586 有两种方式来实现并发性,一种方式是让每个"任务"或"进程"在单 ...
- [OS复习]进程管理3
进程调度方式及类型 1.进程调度方式 根据执行进程的处理机是由进程自己释放,还是被强行剥夺,可以将进程调度方式分为非剥夺方式和剥夺方式两种. 1.1非剥夺方式 执行进程只有在执行完毕,或因申请I/O阻 ...
- OS之进程管理 --- 死锁
什么是死锁 在正常操作模式下,进程按如下顺序来使用资源: 申请:进程请求资源 使用:进程对资源进行操作 释放:进程释放资源 当一组进程中的每一个进程度在等待一个事件,而这事件只能有一组进程的另一个进程 ...
- ActivityManagerService之进程管理(四)
一.初步了解AMS的进程管理 引用邓凡平的深入理解系列的一些知识 1. Linux进程调度优先级和调度策略 调度优先级和调度策略是操作系统中一个很重要的概念.简而言之,它是系统中CPU资源的管理和控 ...
最新文章
- 快速部署RDA Remote Diagnostic Agent
- 中科院博士因论文致谢走红后,回到母校演讲再刷屏!网友:是对寒门学子最好的激励...
- mysql utf8mb4 java_mysql中utf8和utf8mb4区别
- 广西计算机一级考试是机考吗,广西计算机一级考试机考模式探索及应用.doc
- she is so css什么意思,输入she is so什么意思 微信she is so什么梗
- MTK 驱动---(11) EMI定制
- 工作中任务管理的四个原则和四个技能
- spring 4.x下让http请求返回json串
- [加壳脱壳] VMP壳原理简介
- linux把m4s格式转换mp4,批量将哔哩哔哩缓存M4S格式视频改成MP4格式
- 单细胞测序系列之三:单细胞转录组测序
- java web服务_如何用Java实现Web服务器
- [论文阅读] (23)恶意代码作者溯源(去匿名化)经典论文阅读:二进制和源代码对比
- 常用的几种集合(Map另写)
- 用Python实现斗地主游戏(终端版)
- BS架构和CS架构的比对
- 移动联通电信wap和net接入点判断
- 宽度优先搜索算法(BFS)详解(超级详细讲解,附有大图)
- 上班族的英语学习计划
- 磁性元器件的分布参数
热门文章
- 【Qt】Qt窗口程序
- 【Linux】一步一步学Linux——consoletype命令(247)
- 【Linux】一步一步学Linux——curl命令(193)
- 【工具类】工具相关参考文档汇总
- redis 一般启动几个 哨兵_Redis 5.0.8 主从+哨兵的搭建
- 每天一道LeetCode-----计算给定序列中所有长度为k的滑动窗的最大值集合
- 搜索旋转排序数组—leetcode31
- android 屏幕禁止,Android应用禁止屏幕休眠的几种方法
- php 进制 小数,小数进制转换
- HDU Problem - 2732 Leapin' Lizards(最大流,拆点建边)