1 votos

KeepAlive con NetworkState no funciona para el agente

Estoy tratando de ejecutar automáticamente un script de Python</strkeep><strkeep> todos los días, pero requiere una conexión a Internet (para enviar correos electrónicos, etc.). Así que he fijado la fecha y la hora en la que debe ejecutarse, pero si no hay red disponible, quiero que se ejecute en cuanto encuentre una red. Pensé que lo siguiente haría justo lo que necesito:

<?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.example</string>

    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/python</string>
        <string>/path/to/my/script.py</string>
    </array>

    <key>StartCalendarInterval</key>
    <dict>
      <key>Hour</key>
      <integer>10</integer>
      <key>Minute</key>
      <integer>30</integer>
    </dict>

    <key>KeepAlive</key>
    <dict>
      <key>NetworkState</key>
      <true/>
    </dict>

  </dict>
</plist>

Funciona bien cuando tengo conexión a Internet a las 10:30, pero cuando no tengo red disponible sino que la recupero, por ejemplo, a las 11:00, no ejecuta el script y no hace nada durante el resto del día.

¿Qué he hecho mal?

Muchas gracias,

3voto

Consulte la página de manual ( man launchd.plist ) para ver si NetworkState está implementado.

Para mí, en macOS Mojave, no lo es:

KeepAlive <boolean or dictionary of stuff>

This optional key is used to control whether your job is to be kept continuously running
or to let demand and conditions control the invocation. The default is false and therefore
only demand will start the job. The value may be set to true to unconditionally keep the
job alive. Alternatively, a dictionary of conditions may be specified to selectively control
whether launchd keeps a job alive or not. If multiple keys are provided, launchd ORs them,
thus providing maximum flexibility to the job to refine the logic and stall if necessary.
If launchd finds no reason to restart the job, it falls back on demand based invocation.
Jobs that exit quickly and frequently when configured to be kept alive will be throttled
to conserve system resources.

    NetworkState <boolean>
    This key is no longer implemented as it never acted how most users expected.

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X