Detect boot/reboot and run action

Anybody have a good way to run an action on every startup/reboot?

My first thought is to look for uptimes under 1 hour, and set the action re-apply after an hour. But that won’t catch the reboots in the hour after the first boot (or multi-reboots in following hours).

Any other ideas on ways to get a cross-platform boot-up trigger/signal?

I’m doing something like that. You can have the action set a client setting, and compare the effective date to boot time.

Relevance:

not exists setting "lastruntime" whose (effective date of it > boot time of operating system) of client

Action:

setting "lastruntime"="{now}" on "{now}" for client Do other stuff

I’ve also used something like this, which works with an action set to “reapply whenever it becomes relevant again” and is cleaner because it doesn’t require a setting. It’s something close to this, but maybe not completely right:

not exists action whose (last active time of it > boot time of operating system)

I recall there is a strict way to check that, but I’m not at a console now. I’ll update when I have a chance later today.

1 Like

Thanks Jason! Can’t wait to see what the one-liner is like!

Chris

if not exists last active time of action then true else last active time of action < boot time of operating system

(I suspect my earlier post would probably work as well but I haven’t tested it).