从我的启动作业中收到错误代码 126

问题描述

我正在尝试更多地了解 launchd 以及如何使用它来自动执行某些任务。出于某种原因,当我的非常简单示例作业运行时,它以状态代码 126 退出。我更改了所有文件的权限以确保不是我的问题(因为 126 代码通常有一些事情要做权限),但问题仍然存在。

/Library/launchdaemons/test.plst

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>test.monday</string>
    <key>Program</key>
    <string>/Users/philliptroutman/Desktop/test.sh</string>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>20</integer>
  </dict>
</plist>

/Users/philliptroutman/Desktop/test.sh

#! /bin/sh
echo 'some data' >> /Users/philliptroutman/Desktop/examplefile.txt
echo "some random echo!"

在我加载和卸载 plst 文件后,这就是我得到的

launchctl unload /Library/launchdaemons/test.plist
launchctl load /Library/launchdaemons/test.plist
launchctl list | grep test.monday
-   126 test.monday

我想我的问题很简单……为什么这不起作用?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)