【问题标题】:Running a terminal command every hour [closed]每小时运行一个终端命令[关闭]
【发布时间】:2014-05-08 04:49:28
【问题描述】:

我试图让我的 mac 每小时运行一次 purge 命令,方法是在 /Library/LaunchDaemons 中添加以下 com.user.purge.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.user.purge</string>
    <key>OnDemand</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>purge</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer>
</dict>
</plist>

但它似乎没有运行它。知道为什么吗?

PS。我也在 sudoers 中授予了我的用户无密码权限。

【问题讨论】:

标签: macos bash shell launchd


【解决方案1】:

这里可能会出错。

1) 您需要正确设置您的启动守护程序文件的权限。

Apple's TN2083 (Technote) states:

安装守护程序时,请确保设置文件系统 权限正确。 Apple 建议守护进程由 root 拥有, 拥有一组轮子,并使用权限 755 (rwxr-xr-x) 可执行文件和目录,以及 644 (rw-r--r--) 文件。

2) 你试过通过"launchctl" 加载你的守护进程了吗?

试试这个:

launchctl load /Library/LaunchDaemons/com.user.purge.plist
launchctl start /Library/LaunchDaemons/com.user.purge.plist
launchctl list

看看有没有出现

【讨论】:

    猜你喜欢
    • 2020-03-24
    • 2021-01-15
    • 2023-03-23
    • 2021-03-04
    • 1970-01-01
    • 2022-08-24
    • 2015-12-26
    • 1970-01-01
    • 2019-12-22
    相关资源
    最近更新 更多