Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A while ago my teacher asked me to create a script that would kill Minecraft anytime it came up. It worked when the user themselves ran it, but it didn't if it was at root level.

Is there a command similar to lsof that found all processes, not just ones by the user that called lsof? I read the man page, but I'm not quite understanding it. Is there a lsof command that will get every single process, not just the users'?

This is the script, designed only for Macs:

#!/usr/bin/env python
import os
from time import sleep

while True:
    os.system("lsof | grep minecraft | cut -c 11-16 >mine.txt")
    l = f.readline()
    if len(l) > 0:
        os.system("kill "+l)
    os.system("echo > mine.txt")
share|improve this question
Hey could I get my hands on that script? I could use it. I'd also like to expand it's capabilities so source code would be nice. – Griffin Mar 9 '13 at 2:51
@Griffin Sure I'll edit into the question. It's fairly simple. – Hovestar Mar 9 '13 at 2:54
Actually that's an even better idea. Showing them the source might give them a better understand of what to change. Sadly I can not help because I'd don't know but other who do might find it useful. – Griffin Mar 9 '13 at 2:55
why are you using lsof? it's designed to list open files. i think it'd be better to use something like ps. and as for listing the processes of all the users... if memory serves, that's impossible, as it's a potential security issue – nc4pk Mar 9 '13 at 3:04
:( Me no know python. How you do in C++ – Griffin Mar 9 '13 at 3:09
up vote 2 down vote accepted

This prints the names of all processes:

ps -axco comm | sed 1d
  • -a: all users (like root when run as user and user when run as root)
  • -x: include processes without a controlling terminal
  • -o comm: output only the command column
  • -c: use command names instead of paths in the command column
  • sed 1d: delete the first line (COMM)

If you only want to quit Minecraft, you could run a shell script like this (or just killall minecraft with launchd or cron):

while sleep 5; do killall minecraft 2> /dev/null; done
share|improve this answer
Perfect thank you very much! – Hovestar Mar 9 '13 at 19:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.