我想在Mac启动时运行Shell脚本。为此,我创建了一个shell脚本和plist文件。我已将plist复制到~/Library/LaunchAgents/com.example.exampld.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.example.exampld</string>
<key>ProgramArguments</key>
<array><string>/Users/dhiraj/.mydir/startup.sh</string></array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
我已使用以下commond
加载了它sudo launchctl load -w ~/Library/LaunchAgents/com.example.exampld.plist
并且也使用
进行了测试sudo launchctl start ~/Library/LaunchAgents/com.example.exampld.plist
但是shell脚本代码没有执行,我可以这么说是因为我的shell脚本如下所示启动了go构建并打开浏览器,但是什么也没有发生。
echo #start up go build#
$HOME/.mydir/./go
open http://localhost/sample/index.html
答案 0 :(得分:0)
var $offerLink1 = '/content/revamp/en/hotels/india/offers/purchase.html';
var $offerLink2 = '/content/revamp/en/offers/quick-deal.html';
const re = /(?:\/[^/]+){3}/;
console.log(
$offerLink1.replace(re, ''),
$offerLink2.replace(re, '')
);
在 local 域(sudo launchctl load
)中加载启动的代理/守护程序。
在用户域中,您必须不带/Library/..
来呼叫launchctl