I want to run a shell script on mac startup. For that i have created a shell script and plist file. I have copied the plist to ~/Library/LaunchAgents/com.example.exampld.plist
. It has all required permissions.
<?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>
I have loaded it using below commond
sudo launchctl load -w ~/Library/LaunchAgents/com.example.exampld.plist
And also tested using
sudo launchctl start ~/Library/LaunchAgents/com.example.exampld.plist
But the shell script code is not executed i can say this because my shell script start a go build and open browser as below but nothing happens.
echo #start up go build#
$HOME/.mydir/./go
open http://localhost/sample/index.html