Automatic Startup On MacOS XHow can I make a program start automatically after I login to MacOS X? (Or when the computer starts if MacOS logs in automatically.)
How can I make the MacUnix version of KDX Server start automatically after I login to MacOS X? (Or when the computer starts if MacOS logs in automatically.)Use the same instructions as for the previous question. KDX Server will appear in a window in Apple's Terminal program. Optional: If you would prefer that it started invisibly, then you can create an AppleScript (as follows) which starts KDX Server, and use the above instructions to make the AppleScript automatically run. To create the AppleScript, open Apple's "Script Editor" program, type/paste the following in, and save it:
tell me Note that there should only be 4 lines (the "do shell script" line is so long that it requires 2 lines to display here, but it is actually only 1 line). You will need to replace the text "User/john/Documents/KDXServerFolder" in the script with the location of the KDX Server program (KDXServer.command) on your hard disk. You can find this by opening Apple's Terminal program, and drag & drop the KDXServer.command file into the Terminal window. It will then display the path/location, which you can then copy & paste to the script. Also note that before you do all this, you will need to have run KDX Server normally for the first time by double-clicking it in order to configure the initial settings (choose an admin password etc).
How can I make KDX Server startup BEFORE login (as a daemon) in MacOS X when the computer starts?Advanced users only: Firstly, note that MacOS X does not seem to support this for any program that displays a GUI (Graphical User Interface). It seems to be only supported for unix CLI (Command Line Interface) programs. Thus you are forced to use the MacUnix version of KDX Server instead of the GUI version. UPDATE 23Sep05: In Mac OS X v10.4 Tiger, Apple introduced a new system startup program called launchd, which they say is the preferred method for starting a server program when the computer starts. We have not tested this method yet, but you can read the information about it on the Apple website. UPDATE 09Jan06: KDX Server for MacUnix can be used with the above-mentioned launchd. Thanks to Rick who provided the following instructions. He made a .plist text file containing the following and put it in /Library/LaunchDaemons. You may need to change it for your particular setup. <?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>Label</key> <string>com.haxial.kdxerver</string> <key>ProgramArguments</key> <array> <string>/Applications/KDXServer1600-Mac/KDXServer.command</string> <string>--bkgnd</string> <string>--nohup</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>Here is another sample working plist file, thanks to Ritchie. Again change to suit your particular system. <?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>Label</key> <string>com.haxial.kdxserver</string> <key>ServiceDescription</key> <string>kdx server daemon</string> <key>Program</key> <string>/apps/bin/kdx server/KDXServer.command</string> <key>RunAtLoad</key> <true/> <key>OnDemand</key> <false/> <key>UserName</key> <string>username</string> <key>GroupName</key> <string>admin</string> <key>Umask</key> <integer>22</integer> <key>WorkingDirectory</key> <string>/apps/bin/kdx server/</string> <key>StandardErrorPath</key> <string>kdxservererror_log</string> <key>StandardOutPath</key> <string>kdxserver_log</string> </dict> </plist>More info: UPDATE 23Sep05: Thanks to Stephan who sent us a message to say that he was able to make the StartupItem method (see following) work on his installation of MacOS X 10.4. Here is a screenshot of his setup. Make sure that all files have the proper access permissions. [OLD, USE ABOVE LAUNCHD METHOD INSTEAD] Original Information: Please see the following documentation on the Apple website:
After looking at those webpages, you are probably going to say to us something like, "Those instructions are bullshit! How the fuck do you expect me to follow that?!?!" You are correct. In fact, we tried to follow Apple's instructions for a whole day, trying both the /Library/StartupItems and the /etc/mach_init.d methods, and still could not make it work. Apple has designed this very poorly. "Designed" is not even the correct word here. Monkeys could design a better method for starting programs before login. It should actually be a simple task, but Apple has complicated it beyond recognition (the same has also happened in other operating systems). If anyone manages to make it work, please write precise step-by-step instructions and send them to Haxial, for the benefit of everyone who would like to know how to do this. When starting KDX Server, you will probably want to try to start it like this: /path/KDXServer.command --bkgnd --nohupThe "--bkgnd" option makes KDX Server run as a child process, and then the parent process exits. In other words, executing the above command will return control to your script (or whatever) promptly, while leaving the server running in the background. The "--nohup" option makes KDX Server ignore requests to terminate that are caused by closing the terminal/shell window etc. Here are some files that you might find useful:
|