Skip to content

Instantly share code, notes, and snippets.

@artyom
Created May 30, 2017 14:09
Show Gist options
  • Select an option

  • Save artyom/07635c1e3a330c3d08469758452f7bc3 to your computer and use it in GitHub Desktop.

Select an option

Save artyom/07635c1e3a330c3d08469758452f7bc3 to your computer and use it in GitHub Desktop.
kill rogue distnoted
~ ¶ cat .bin/org.acme.kill_distnoted.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.acme.kill_distnoted</string>
<key>Program</key>
<string>/Users/artyom/.bin/checkdistnoted</string>
<key>ProgramArguments</key>
<array>
<string>/Users/artyom/.bin/checkdistnoted</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
~ ¶ cat .bin/checkdistnoted
#!/bin/sh -eu
export PATH=/bin:/usr/bin
ps -Ao '%cpu,uid,pid,command' | \
awk -v UID=$UID '/distnoted agent$/&&$1>100.0&&$2 == UID{system("kill -9 " $3)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment