how to open daytime service on mac using launchctl?

839 Views Asked by At

well, there is solution on internet to linux's daytime service startup. But I can not find solution to Mac. I don't know if I should find the executable of daytime first, and then write a .plist file, or just there is something built-in, all I need to do is just like on linux -- that is 'turn disable to NO'.

1

There are 1 best solutions below

2
On

I'm afraid I don't have enough rep to comment so please excuse the answer;

Taken from here

  1. Use the Boost.ASIO library for C++ server and client
  2. Compile the server as 'boost_daytime_server' and linked into /usr/local/bin/
  3. Drop the following plist file into /Library/LaunchDaemons
<?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">
    <plist version="1.0">
    <dict>
            <key>Debug</key>
            <false/>
            <key>GroupName</key>
            <string>staff</string>
            <key>Label</key>
            <string>my_organisation.daytime</string>
            <key>OnDemand</key>
            <false/>
            <key>Program</key>
            <string>/usr/local/bin/boost_daytime_server</string>
            <key>ServiceDescription</key>
            <string>Daytime Server with Boost</string>
            <key>UserName</key>
            <string>root</string>
    </dict>
    </plist>
  1. And load into OS X
sudo lauchctl load /Library/LaunchDaemons/my_organization.daytime.plist

We can test the client using:

./client schorsch.efi.fh-nuernberg.de