Use of 'log stream --predicate' to exit as soon as event is detected

Teddos

New member
Joined
Aug 24, 2022
Messages
1
Reaction score
0
Points
1
Hello,

I'm trying to write a simple script that monitors starting and stopping an application. It would then send an appropriate message using MQTT on my network. For instance, to automatically turn on and off some lights using Home Assistant. The latter runs on a RPi.

The application in question is OBS and i can detect the start and stop events using the following log commands:

log stream --predicate 'composedMessage contains "com.obsproject.obs-studio" and composedMessage contains "CHECKIN"'
log stream --predicate 'composedMessage contains "Removing process: [app<application.com.obsproject.obs-studio"'

I would like the log to exit as soon as the requested event is triggered. I could then use MQTT to send an appropriate message to the broker.

Any help on how to exit logging would be much appreciated!

Ted.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top