Created
May 30, 2013 09:26
-
-
Save mickhan/5676751 to your computer and use it in GitHub Desktop.
python pidfile
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
import os | |
import sys | |
pid = str(os.getpid()) | |
pidfile = "/tmp/pidfilename.pid" | |
if os.path.isfile(pidfile): | |
print "%s already exists, exiting" % pidfile | |
sys.exit() | |
else: | |
file(pidfile, 'w').write(pid) | |
# Do something | |
os.unlink(pidfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment