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

My friend and I were messing around with our computers bash_profiles and one of us (...) wrote an infinite loop that creates a file on his desktop. The pseudo code looks like this:

while(i > 0)
    echo filename$i

The script ran for about ten seconds creating 200,000 files on his desktop. Now the computer is trying to process the files. Does anyone know how to kill it?

share|improve this question

migrated from Nov 6 '11 at 20:19

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

The original poster's computer can't open up the Task Manager (or Activity Monitor, actually :-) because the Finder is busy trying to digest the thousands of files created on the Desktop. Sounds like an awful mess (that you'll never do again, eh?)

In any event, I'd recommend starting your Macintosh in Single User mode.

Details are here:

You can then rm all those bogus files from the Desktop from there.

I hope this answer helps!

share|improve this answer

you could open task manager, and try to kill it that way, or you could go to processes and kill it that way, or just hit the power button.

Word of advice: Next time don't try that.

And you may still have to delete those files. (They may be off the desktop visible screen, so navigate to your desktop folder)

share|improve this answer

Find out the PID of your amoking script, and kill it (kill 123456). Afterwards, change to the Desktop directory and do rm filename*, provided that only these files start with filename.

share|improve this answer

As one of the other responses said, if you know the process ID use kill <pid> or kill -9 <pid>. But if that information is not available to you, from a terminal you can use top to do that.

You can start top as top -U $USER to show only processes owned by the current user. Once top is running you can sort the processes by whatever you wish by pressing F or O. I would suggest listing by the command name (if you remember which one you ran) or by CPU usage (default). Once you find out the PID, you can kill the process with the k key.

For help with key bindings you can press ? or h.

share|improve this answer

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.