Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Script doesn't run automatically though it is registered in Mac OS X Login Items

I have the following shell script registered in my "Login Items" preferences but it does not seem to have any effect. It is meant to launch the moinmoin wiki but only works when it is run by hand from a terminal window, after which it runs until the machine is next shut down.

#!/bin/bash
cd /Users/stuartcw/Documents/Wiki/moin-1.7.2
/usr/bin/python wikiserver.py >> logs/`date +"%d%b%Y"`.log 2>&1 &

I would really like the Wiki to be available after restarting so any help in understanding this would be appreciated.

like image 513
stuartcw Avatar asked Dec 18 '22 10:12

stuartcw


1 Answers

launchd is one of the best parts of MacOS X, and it causes me great pain to not be able to find it on other systems.

Edit and place this in /Library/LaunchDaemons as com.you.wiki.plist

<?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.you.wiki</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <key>Nice</key>
    <integer>1</integer>
    <key>WorkingDirectory</key>
    <string>/Users/stuartcw/Documents/Wiki/moin-1.7.2</string> 
    <key>UserName</key>
    <string>user to run this as</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/python</string>
        <string>wikiserver.py</string>
    </array>
</dict>
</plist>
like image 181
Dustin Avatar answered Jan 31 '23 09:01

Dustin