Skip to content

Instantly share code, notes, and snippets.

@Drunkar
Last active August 4, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drunkar/7886415 to your computer and use it in GitHub Desktop.
Save Drunkar/7886415 to your computer and use it in GitHub Desktop.
import commands
import sendGmail
from datetime import datetime
from datetime import timedelta
arg = ""
while len(arg) == 0:
arg = raw_input("input substring of process name: ")
INTERVAL = timedelta(seconds=5)
from_addr = "<FROM_ADDR>@gmail.com"
passwd = "<PASS>"
to_addr = "<TO_ADDR>@gmail.com"
title = arg + " end."
body = ""
previous = datetime.now()
while True:
if datetime.now() - previous > INTERVAL:
result = commands.getoutput("ps ax | grep " + arg + " | grep -v grep")
previous = datetime.now()
if arg not in result:
msg = sendGmail.create_message(from_addr, to_addr, title, body)
sendGmail.send_via_gmail(from_addr, to_addr, passwd, msg)
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment