简体   繁体   中英

Launchd 'Invalid Property List'

I was hoping someone could point out where I might be going wrong with a launchctl script I'm trying to write and launch.

The intention is to run a python script I've managed to get working, everyday at 3.15am. (the computer it's going to run on is on 24/7 but if there is a way to incorporate this into it's everyday running that would be great in the event the computer shuts down or needs to be interrupted.)

When I attempt to load the file I get the return message below:

jace@Jaces-Mac-Pro ~ % launchctl load /Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist
/Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist: Invalid property list
jace@Jaces-Mac-Pro ~ % 

According to the tutorial I'm following and a few pages online I've reviewed I should have laid everything out correctly but feel I'm missing something.

If someone could point out my mistake and offer a solution I'd really appreciate it!

Am totally new to this file type and the writing of, but feel it'll be what i need to get the job done.

The file I'm trying to run is the below -

<?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.launch.phoneconfig</string>
       <key>ProgramArgument</key>
    <array>
        <string>/usr/local/bin/python3</string>
        <string>/Users/jace/Desktop/Filing_Cabinet/Python_Folder/Selenium_Projects/my_phone_config01.py</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key
        <integer>3</integer>
        <key>Minute</key>
        <integer>15</integer>
    </dict>
</dict>
</plist>1

Ps

I tried putting the file in my mac's launch Daemon folder but can't seem to locate it in the Library, only 'LaunchAgents' folder can be found. Don't know if this effects anything but let me know if there's more information I could provide to get this running.

Thank you for your time.

I was hoping the code to load and run at the designated time and be returned with the other.plist files when I enter 'launchctl list' into terminal.

Update from comment

(Thanks for pointing this out @Chepner) Running 'putil -lint' allowed me to see an error in script. Example of result.

Before, w/error:

jace@Jaces-Mac-Pro LaunchAgents % plutil /Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist
/Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist: Encountered unexpected character < on line 17 while looking for close tag

After, once fixed:

jace@Jaces-Mac-Pro LaunchAgents % plutil -lint /Users/jace/Desktop/Filing_Cabinet/LaunchD_Folder/launch_phoneconfig/com.launchd.phoneconfig.plist
/Users/jace/Desktop/Filing_Cabinet/LaunchD_Folder/launch_phoneconfig/com.launchd.phoneconfig.plist: OK

Tried running code again but results are as shown -

jace@Jaces-Mac-Pro LaunchAgents % launchctl load /Users/jace/Desktop/Filing_Cabinet/LaunchD_Folder/launch_phoneconfig/com.launchd.phoneconfig.plist
/Users/jace/Desktop/Filing_Cabinet/LaunchD_Folder/launch_phoneconfig/com.launchd.phoneconfig.plist: Invalid or missing Program/ProgramArguments
jace@Jaces-Mac-Pro LaunchAgents % 

Update from Answer

Thank you for the suggestion @Chepner.

Adjusting the line to separate the program and program argument seems to have gotten everything to say 'ok'. Technically this answers my question!

Only problem now is that it doesn't actually run, I can run the python script it's meant to run just fine but can't seem to get it to run via this method. Any suggestions or links I can review to help figure this out?

Thank you for your time in helping me: :)

Last login: Wed Nov 30 14:44:29 on console
jace@Jaces-Mac-Pro ~ % plutil /Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist

/Users/jace/Library/LaunchAgents/com.launchd.phoneconfig.plist: OK

jace@Jaces-Mac-Pro ~ % launchctl list
PID Status  Label
-   0   com.launch.phoneconfig (removed the other items that would be returned to show clearly it loaded)
jace@Jaces-Mac-Pro ~ % 

I think the problem is that you are trying to specify an entire command line as program arguments, rather than specifying the program name separately from its arguments.

<dict>
    <key>Label</key>
      <string>com.launch.phoneconfig</string>
    <key>Program</key>
      <string>/usr/local/bin/python3</string>
    <key>ProgramArgument</key>
      <array>
        <string>/Users/jace/Desktop/Filing_Cabinet/Python_Folder/Selenium_Projects/my_phone_config01.py</string>
      </array>
    <key>RunAtLoad</key>
      <true/>
    <key>StartCalendarInterval</key>
      <dict>
        <key>Hour</key
        <integer>3</integer>
        <key>Minute</key>
        <integer>15</integer>
      </dict>
</dict>

If this is the case, the runtime error could be more specific ( Program is missing, so it could just say so instead of implying that there is a problem with ProgramArguments as well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM