1

I'm having a weird problem. I use launchd to run a bunch of shell scripts that update content on my site. It was working fine when it was just calling scripts normally. But now I made the script a little more complicated, and the launchd plist needs to send an argument when it calls the script. No problem, launchd has ProgramArguments just for that. Problem is, it's just not working. Here is the important part of my launchd.plist:

<key>ProgramArguments</key>
    <array>
        <string>/scripts/content.php</string>
        <string>update</string>
    </array>

I've omitted just a Label key and a StarCalendarInterval key. As you can see, the path to the script is the first element in the array. That seems to be the most common cause of this problem.

So to be clear, this DOES launch my script. But it does NOT pass any arguments. I had the script output print_r($argv) to an error log and it outputs this:

Array ( [0] => /scripts/content.php )

Most important here, is that if I run the following from the command line, my script runs perfectly and as expected: ./content.php update

It seems like I'm doing everything right, I'm not sure what's going on with this?

  • Please add the full plist. Also, did you reload the plist after changing it? – nohillside Jan 6 at 15:09
  • I was typing "of course I reloaded it, and I rebooted!" and now I'm sitting here thinking.... did I? I might not have, I might have only loaded the 'twin' I split off of this. That might be it after all. – l008com Jan 6 at 15:14
  • @nohillside looks like that was the problem! I loaded the new .plist I made for the other argument, but I never re-loaded this plist when I added an argument here! – l008com Jan 6 at 15:22
1

If you edit a .plist you need to run launchctl unload ... and launchctl load ..., otherwise the system will keep using the previous (cached) version.

  • Indeed you do. I had duplicated this script, added some stuff to the duplicate, and loaded it correctly. But I forgot to unload and re load the original, which I also changed. – l008com Jan 6 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .