Use LAUNCHD to implement power-on Start command with Rc.local under Mac

Source: Internet
Author: User

In fact, the principle is very simple, using LAUNCHD to create a start-up service, and then the service associated/etc/rc.local file, then the next operation Rc.local and Linux under the same.

Of course, this idea can also be used directly on the ~/.BASHRC file, but this way has a disadvantage, that is, permissions are not root, so the scope of application is much smaller. The user who executes the script inside the file created by this service is root and has the highest permissions.

Description: About LAUNCHD users directly on the Apple developer site query, clues can be this launchctl

Implementation steps:

Go to /Library/LaunchDaemons Catalog

Cd/library/launchdaemons

Create a plist file

sudo vim local.localhost.startup.plist

Copy the following to the file save. (Press "ESC", then ": wq!", enter)

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE plist Public "-//apple computer//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd "><plistversion= "1.0">    <Dict>        <Key>Label</Key>        <string>Local.localhost.startup</string>        <Key>Disabled</Key>        <false/>        <Key>Runatload</Key>        <true/>        <Key>KeepAlive</Key>        <false/>        <Key>Launchonlyonce</Key>        <true/>        <Key>Programarguments</Key>        <Array>            <string>/etc/rc.local</string>        </Array>    </Dict></plist>

Adding as a service using LAUNCHCTL

sudo launchctl load-w ./local.localhost.startup.plist

Finally, create the rc.local file,

sudo vim/etc/rc.local

Write the commands that need to be executed on the inside. Remember to give the rc.local file x permission (executable)

sudo chmod +x/etc/rc.local

Reference:

http://blog.csdn.net/maxsky/article/details/55061453 (the above content is transferred from this article, the deletion of the dialogue)

http://blog.csdn.net/abby_sheen/article/details/7817198

Use LAUNCHD to implement power-on Start command with Rc.local under Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.