Created
May 30, 2017 14:09
-
-
Save artyom/07635c1e3a330c3d08469758452f7bc3 to your computer and use it in GitHub Desktop.
kill rogue distnoted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~ ¶ 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