虽然Shell脚本在Mac OS X登录项中注册,但它不会自动运行

时间:2022-11-17 01:07:46

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.

我在“登录项”首选项中注册了以下shell脚本,但似乎没有任何效果。它的目的是启动moinmoin wiki,但只有当它从终端窗口手动运行时才能工作,然后运行直到机器下次关闭。

#!/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.

我真的希望Wiki在重新启动后可用,所以任何帮助理解这一点都将受到赞赏。

4 个解决方案

#1


4  

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.

launchd是MacOS X最好的部分之一,它让我很难在其他系统上找不到它。

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

编辑并将其放在/ Library / LaunchDaemons中,如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>

#2


4  

Try using launchd. More info at http://www.macgeekery.com/tips/all_about_launchd_items_and_how_to_make_one_yourself

尝试使用launchd。更多信息,请访问http://www.macgeekery.com/tips/all_about_launchd_items_and_how_to_make_one_yourself

#3


3  

Some helpful links:

一些有用的链接:

Mac OS X: Creating a login hook

Mac OS X:创建登录挂钩

Making Shell Scripts Start at Login or System Startup

使Shell脚本在登录或系统启动时启动

See also Lingon for a front end, should you decide to use Launchd instead.

如果您决定使用Launchd,请参阅Lingon的前端。

#4


1  

I don't know much about it, since I don't use login items. Just a suggestion, maybe try with applescript that calls those shell commands, and put that in Login Items.

我不太了解它,因为我不使用登录项。只是一个建议,也许尝试使用调用那些shell命令的applescript,然后将其放入Login Items中。

#1


4  

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.

launchd是MacOS X最好的部分之一,它让我很难在其他系统上找不到它。

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

编辑并将其放在/ Library / LaunchDaemons中,如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>

#2


4  

Try using launchd. More info at http://www.macgeekery.com/tips/all_about_launchd_items_and_how_to_make_one_yourself

尝试使用launchd。更多信息,请访问http://www.macgeekery.com/tips/all_about_launchd_items_and_how_to_make_one_yourself

#3


3  

Some helpful links:

一些有用的链接:

Mac OS X: Creating a login hook

Mac OS X:创建登录挂钩

Making Shell Scripts Start at Login or System Startup

使Shell脚本在登录或系统启动时启动

See also Lingon for a front end, should you decide to use Launchd instead.

如果您决定使用Launchd,请参阅Lingon的前端。

#4


1  

I don't know much about it, since I don't use login items. Just a suggestion, maybe try with applescript that calls those shell commands, and put that in Login Items.

我不太了解它,因为我不使用登录项。只是一个建议,也许尝试使用调用那些shell命令的applescript,然后将其放入Login Items中。