Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use launchctl in Mac

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use launchctl in Mac. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

There is a command-line tool in Mac called launchctl, which can be used to control the automatic startup or shutdown of services. The general grammar is

Sudolaunchctlload/path/to/service.plistsudolaunchctlunload/path/to/service.plist .

Where's launchctl?

Generally, plist files are placed in several places:

/ Library/LaunchDaemons/ daemon task items defined by the administrator

/ Library/LaunchAgents/ A task item defined by the administrator for the user

~ / Library/LaunchAgents/ task items defined by the user

/ System/Library/LaunchAgents A task item defined by MacOSX for the user

You can write a plist file under ~ / Library/LaunchAgents/, which describes your program path and startup parameters, then the user will start the program when he logs in, and it can't be killed.

Automatically restarts after being killed.

If you need to stop it, run the command

Launchctlunload~/Library/LaunchAgents/com.yourcompany.porduct

If you put it under / Library/LaunchAgents/, it will start as soon as it is turned on.

Launchctl: controls the startup process in the OSX system (launch)

Execute scheduled script | set boot steps

(1) write and execute scripts

Usually brew is automatically generated for us when brew installs the software.

(2) create plist files in the corresponding directory

(3) load service

Note: the plist under the Agents folder needs to be loaded after the user logs in, while the plist under the Daemons folder will be loaded as long as it is turned on without logging in.

Load / unload services

Cd enters the specified plist file directory

Launchctlload*.plist# loading

Launchctlunload*.plist# cancel

Launchctllist# View Service

This is the end of the article on "how to use launchctl in Mac". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report