Created
April 2, 2015 08:46
-
-
Save matstani/cf15a568a6ca4c273773 to your computer and use it in GitHub Desktop.
Rubyスクリプト二重起動チェック
This file contains 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
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