Skip to content

Instantly share code, notes, and snippets.

@matstani
Created April 2, 2015 08:46
Show Gist options
  • Select an option

  • Save matstani/cf15a568a6ca4c273773 to your computer and use it in GitHub Desktop.

Select an option

Save matstani/cf15a568a6ca4c273773 to your computer and use it in GitHub Desktop.
Rubyスクリプト二重起動チェック
def already_running?
p_name = `cat /proc/#{$$}/cmdline | xargs --null`.strip()
pid = `pgrep -oxf "#{p_name}"`.strip()
pid != $$.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment