Skip to content

Instantly share code, notes, and snippets.

@phromo
Last active May 14, 2018 11:28
Show Gist options
  • Save phromo/6a41be2bc4d716751eee2eb29856d4bb to your computer and use it in GitHub Desktop.
Save phromo/6a41be2bc4d716751eee2eb29856d4bb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'sys/proctable'
require 'rufus-scheduler'
include Sys
def is_org_running()
ProcTable.ps do |p|
return true if p.comm.include? "Xorg"
end
return false
end
def aw_pids()
pids = []
ProcTable.ps do |p|
next unless p.comm.include? "aw-watcher"
pids << p.pid
end
return pids
end
def main_awkiller()
return [] if is_org_running()
procs_kill = aw_pids()
procs_kill.each do |pid|
Process.kill("HUP", pid)
end
return procs_kill
end
scheduler = Rufus::Scheduler.new
scheduler.every '1m' do
main_awkiller().each do |pid|
puts "killed pid #{pid}"
end
end
puts "awkiller.rb starting main loop, checking every 1m"
main_awkiller().each do |pid|
puts "killed pid #{pid}"
end
scheduler.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment