It seems that a fairly popular trigger would be a job that runs once, when the computer is restarted or user logs in. But I don't see a key for this in launch.plist(5). To get that effect, I'm using the two keys StartOnMount + LaunchOnlyOnce. The former does the job because a filesystem must be mounted when a computer restarts, and the latter keeps it from starting multiple times in case another filesystem is mounted before it exits. This works, but is indirect and kludgey. Is there a better way to do this? The reason I want to do this is to restart a syncing task which may take a minute or so and thus could be interrupted by system shutdown. When my task begins, it loads this new "standby" StartOnMount+LaunchOnlyOnce agent to re-run the same task when the system starts up. But when my task ends normally, it unloads this agent. Therefore it only ever spawns if my task was interrupted. Thank you, Jerry Krinock
You should probably use "RunAtLoad" instead of "StartOnMount". Thomas On 24 mai 2011, at 00:15, Jerry Krinock wrote:
It seems that a fairly popular trigger would be a job that runs once, when the computer is restarted or user logs in. But I don't see a key for this in launch.plist(5).
To get that effect, I'm using the two keys StartOnMount + LaunchOnlyOnce. The former does the job because a filesystem must be mounted when a computer restarts, and the latter keeps it from starting multiple times in case another filesystem is mounted before it exits. This works, but is indirect and kludgey.
Is there a better way to do this?
The reason I want to do this is to restart a syncing task which may take a minute or so and thus could be interrupted by system shutdown. When my task begins, it loads this new "standby" StartOnMount+LaunchOnlyOnce agent to re-run the same task when the system starts up. But when my task ends normally, it unloads this agent. Therefore it only ever spawns if my task was interrupted.
Thank you,
Jerry Krinock
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
On 2011 May 24, at 01:01, Thomas Clement wrote:
You should probably use "RunAtLoad" instead of "StartOnMount".
Ah, hand hits forehead. You see, in my apps, I use my addLaunchdAgent routine which writes the plist file and then spawns launchctl to *load* it. So for years now, I've always thought of installing and loading as a single operation, unlike everyone else who installs their task and then wonders why it doesn't work. So, I'd thought that if I "added" "RunAtLoad" it would run immediately when I added it, which was not acceptable. The obvious solution is to not install but not load it. Now I understand why no one else ever asked this :)) Thank you, Thomas. Jerry
participants (2)
-
Jerry Krinock
-
Thomas Clement