I have created a .plist file in order to run a Python program when I start up my Mac. The following is my .plist file, myprogram.plist:
<?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>myprogram.name</string>
<key>ProgramArguments</key>
<array>
<string>/Users/louiscage/PycharmProjects/myprogram/myprogram.command</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The string in the .plist file is the path to my Python script, which I had made executable by using "chmod +x" in the terminal.
However, when I enter
launchctl load /Library/LaunchAgents/myprogram.plist
into the terminal, which is the path to my .plist file, there doesn't seem to be any errors. This leads me to believe my .plist was loaded successfully to LaunchD. But when I enter
launchctl start /Library/LaunchAgents/myprogram.plist
, my program does not start.
Also, when I restart my Mac, the program still does not start, even if I had loaded it to LaunchD.
Any help towards why this .plist file does not start using LaunchD would be greatly appreciated.
launchctl list myprogram.name(note that this uses the Label, not the filename) show? Look particularly for"PID" =(which would indicate it's running) and"LastExitStatus" =(if nonzero, that means the program errored out last time it was run). Also, addStandardOutPathandStandardErrorPathto the plist pointing to log files, unload and reaload it, and see what they contain.printstatements to your script to indicate what's going on (and hopefully point to what's wrong). Oh, and did you checklaunchctl list myprogram.name? That should give at least a little info about what's happening.