Launchd to terminate what it starts

launchd

I have a launchd plist that uses StartCalendarInterval to start my python script at the desired time and day of the week.

Now I want to create a launchd plist that both starts and terminates a different python script at selected times. Where is the "KillCalender" command or equivalent?

Essentially, I want the program the controls my Christmas lights come on at 1800 and go off at 2200.

I suppose I could write the main loop in my python program so it terminates at 2200 but I was hoping launchd could do this for me.

Best Answer

I would look into the ExitTimeOut value for launchd.plist:

TimeOut

The recommended idle time out (in seconds) to pass to the job. If no value is specified, a default time out will be supplied by launchd for use by the job at check in time.

ExitTimeOut

The amount of time launchd waits before sending a SIGKILL signal. The default value is 20 seconds. The value zero is interpreted as infinity.