How to close open (20+) notification windows from terminal or disable HP Alerts?

Posted on


For some strange reason an app called “HP Alerts” filled my screen overnight with notification windows telling me one of my inkjet cartridges are low on ink. I have now disabled these notifications but would like to know if there is some way of closing all these notification windows with a terminal command?

EDIT: I eventually got rid of the windows by creating an Automator action—looping 100 times—that keeps on closing “HP Alerts” windows until none are left. I’m still curious to know if it could be done without looping in “Terminal.”


I’ve had less than stellar past experiences with HP printer driver for years so while I’m not surprised by this, I don’t use their product drivers. That said, you can probably use ps to get the PID of the app, use awk or cut to get the PID then kill the PID. Here’s an example using Safari.

First get the PIDs for Safari. The second grep excludes grep Safari from the results

$ ps -ef|grep Safari|grep -v grep
200000000   269     1   0  9:45AM ??         0:18.99 /Applications/ -psn_0_61455
200000000   560     1   0  9:46AM ??         0:00.13 /usr/libexec/SafariNotificationAgent
200000000   602     1   0  9:46AM ??         0:00.32 /System/Library/PrivateFrameworks/Safari.framework/Versions/A/XPCServices/

The columns for ps -ef are UID, PID, PPID, C, STIME, TTY, TIME and CMD. We’re interested in the second column, hence

$ ps -ef|grep Safari|grep -v grep|awk '{print $2}'

From here, you can use xargs to pass this info to kill. Note that this will only work if you own the process and they respond to termination without any additional kill options

$ ps -ef|grep Safari|grep -v grep|awk '{print $2}'|xargs kill
$ $ ps -ef|grep Safari|grep -v grep
-bash: $: command not found

The error message returned from the second command shows that Safari no PID with that name is visible.

Leave a Reply

Your email address will not be published. Required fields are marked *