Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

i=1
while(i > 0)
do
    i=++
    echo filename$i
done

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 stackoverflow.com Nov 6 '11 at 20:19

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

4 Answers 4

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: http://support.apple.com/kb/ht1492

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

 
discard

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.