I have several plists set up on my Mac to run several scripts(php) at different intervals over the course of the day. They connect to a website I have (on an external server) and scrape specific information to store in a local database.
All of this worked well until recently when I noticed my database was not getting updated. I placed a few debugging lines of code (write to a text file) inside the scripts that are supposed to be running to see where the error occurs and I think I have narrowed it down to a specific line.
// write to a text file1.txt
$base = "http://www.mywebsite.com/";
$html = file_get_html($base); // This is the line that causes the script to stop running
// write to a text file2.txt
file1 is written to, but file2 is not written to.
In trying to determine why the script stopped running I looked inside the system.log and noticed this error specifically referring to the plists that should have been launchd
Nov 30 11:43:35 My-iMac com.apple.xpc.launchd[1] (com.whatever.whatever[19088]): Service exited with abnormal code: 255
I unloaded and then loaded all of the plist from terminal:
sudo launchctl unload -w /Library/LaunchDaemons/com.whatever.whatever.plist
sudo launchctl load -w /Library/LaunchDaemons/com.whatever.whatever.plist
I also thought perhaps it was a permissions problem that somehow changed so I:
sudo chown root:wheel /Library/LaunchDaemons/com.nhlrankking.playerstats3.plist
However, they are still not being run completely and get 'stuck' at that same line of code.
If I run the scripts manually, they work fully with no problems or errors.
I'm not sure if it helps, but the Mac is running High Sierra, and I believe the problem occurred roughly around the same time I downloaded the 'Mojave' OS (but I have not yet installed)
I appreciate any help you can give me in solving this problem. I don't have a lot of experience with launchd, and ssh so I'm hoping it's a simple bug, but all searches so far have been fruitless.
----Edit---- Here is the plist file (I know it begins running at the proper time):
<?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>com.whatever.whatever</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/php</string>
<string>/Users/My/Sites/Launchd/my_script.php</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</dict>
</plist>