I have 2 computers both running tasks with KM even when I'm not sitting by them. Because I'm not by these computers often, sometimes KM in one of the computers will close. I'm hoping the other computer's KM will detect this within an hour or so (doesn't need to be real time alerts) and send me an email. I know how to use Remote Trigger and send an email with KM but I can't figure out how to do this in a way that doesn't involve creating a ton of variables and several macros on each computer to make this work. Any suggestions would be appreciated.
Hi, @itucker8; welcome to the Keyboard Maestro forum!
Since you are a new forum user, I'm going to refer you to three references that will make your time here much more efficient:
- Getting Started with Keyboard Maestro and the Forum
- How Do I Get The Best Answer in the Shortest Time to Questions on the KM Forum?
- How to Post/Upload Your Macro to the Forum
Do you mean the Keyboard Maestro Engine is no longer running? If so, maybe you could open the
Engine.log to diagnose the issue. See Help>Open Logs Folder.
With that said, you could create a macro that includes the Execute a Shell Script action. In the action you could enter the following shell commands:
ssh username@macname_or_ipaddress 'pgrep "Keyboard Maestro Engine" > /dev/null' if [ $? -eq 0 ]; then echo "1" # KM Engine is running on remote Mac. else echo "0" # KM Engine is not running on remote Mac. fi
If you aren't familiar with
ssh and keys, check out this page: How to Use SSH-Keygen to Generate an SSH Key on Mac
Hi Iona, welcome to the forum!
Here's two reasons not to listen to me:
To make explicit what I believe @_jims was implying: the Keyboard Maestro Engine should not randomly and frequently stop running. If that is the case, the underlying issue is worth investigating.
Addressing your question directly, Jim's recommendation is stable and elegant and I also endorse understanding SSH as an option for any task involving remote machines.
With all that said, this can be done simply with a Remote Trigger:
less elegant solution
From the wiki on Remote Triggers: "The result from the server is the number of listening macros that the server currently knows about"
With this, you can set up a "request" action on Mac-A that triggers a "received" action on Mac-B. If Mac-B returns
1, Mac-B is working. The "received" action does not need to actually do anything.
Consider: whether using SSH or a Remote Trigger, you will have to deal with failures and false positives if the target Mac is off or otherwise offline.
To re-reiterate: I recommend figuring out what's breaking in the first place, and this forum is a great place to help diagnose the issue.
Thank you guys. Both of these work great. KM is shutting down once every couple days which made me assume it was just taking up too much memory over time. I never checked the activity monitor though and am looking at the logs now for the first time and seeing several issues mentioned in the forum.