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.

Every time I launch either iTerm or Terminal after not using it for a few hours, it takes anywhere from 10-20 seconds to return a prompt. The screen is blank, and although I can type I can't actually run any commands.

If I quit either application, subsequent launches (if done relatively soon thereafter) are quite fast. The slowness only seems to occur if the app wasn't running for a few hours.

I'm running OSX 10.5.7 on a MacBookPro. I have the exact same setup on another computer, with no slow downs.

Any ideas how to speed things up again?

share|improve this question
    
I love how this question is asked and answered by two anonymous users with random numbers. I don't see this pattern that often! :) –  Cawas Apr 13 '11 at 15:59

7 Answers 7

up vote 33 down vote accepted

Try deleting the Apple system log files in /var/log/asl/:

sudo rm /var/log/asl/*.asl

This did the trick for me.

share|improve this answer
2  
(ASL = Apple System Log) –  Arjan Sep 28 '09 at 8:55
    
This is the one that worked. Thanks! –  pmaiorana Sep 28 '09 at 13:28
5  
As pointed out on OsXDaily, I'd recommend using sudo rm -rf /private/var/log/asl/*.asl instead because it's safer as it 1) only deletes the log files and 2) avoids cding into the wrong directory and removing all files. –  Matthew Rankin Feb 24 '11 at 12:34
1  
Anyone have any idea why the size of system logs effect how fast the terminal opens? –  James McMahon Aug 2 '12 at 4:10
3  
@JamesMcMahon The login process seems to read all files and folders on the top level of /var/log/asl. Try running sudo opensnoop | grep /var/log/asl. –  ؘؘؘؘ Aug 6 '12 at 9:59

If the terminal application has loaded but you don't have a prompt yet then it's your shell taking a while to initialise.

This probably means you have too much or something time consuming in your .bashrc (assuming you use bash).

share|improve this answer
    
This might be the problem I'm having, do you know how I can check If I'm using bash where I can access the .bashrc file? –  alvincrespo Oct 25 '11 at 13:45

My guess is that over time, something is using a lot of memory. When you startup a terminal after not using it for a while, some memory has to be made available by swapping its contents out to disk. If you kill the terminal process and restart it relatively quickly the memory is still available and it starts up quickly. This should happen with other applications as well.

You should monitor your memory usage with Activity Monitor and see if you can tell where it is going.

share|improve this answer
    
He said that the Terminal window was open which means the process has loaded. –  Mike McQuaid Aug 30 '09 at 10:52
1  
@Mike, I am not sure that once the Terminal window is shown, everything has loaded? Still, if the above would be true for Terminal, then any program would launch slowly. I don't think Terminal needs a lot of resources (6.5/31.7 real/virtual on my Mac), so @pmaiorana: how much memory does Terminal needs on your Mac? –  Arjan Sep 28 '09 at 8:52

From an article I read a couple weeks ago: Slow Opening Terminal Windows

/usr/libexec/path_helper is terribly slow at loading /etc/paths If you remove all the entries in /etc/paths and ensuring that those items are available in your .bash_profile this will resolve the issue. It did for me anyway.

share|improve this answer
    
Coincidentally someone rewrote path_helper and it's available at: github.com/mgprot/path_helper –  Chealion Oct 26 '09 at 19:46

Am I required a certain reputation to comment on posts? Anyway clearing the system logs did it for me as well, thanks. I have tried to patch path_helper with the patch here: gist.github.com/123525, as suggested in a comment on http://mjtsai.com/blog/2009/04/01/slow-opening-terminal-windows/ (referenced earlier in this thread) but to no avail. I get a cryptic error. However, that patch should speed up terminal.app launch.

addition: As I mentioned, clearing the logs did the trick for me, but the problem continues to emerge as the logs continously grow bigger after I've removed them. I found that "tweaking" /etc/asl.conf has given me a more permanent solution. The modification is to log only messages that are categorised as "critical" or more critical than that, as opposed to logging "notice" category and every more critical than that. Also, I disregard messages from ftp, mail, local0, local1. Here's a paste of my /etc/asl.conf:

 ##
 # configuration file for syslogd and aslmanager
 ##

# redirect com.apple.message.domain to /var/log/DiagnosticMessages
? [T com.apple.message.domain] store_dir /var/log/DiagnosticMessages exclude_asldb

# authpriv messages are root/admin readable
? [= Facility authpriv] access 0 80

# remoteauth critical, alert, and emergency messages are root/admin readable
? [= Facility remoteauth] [<= Level critical] access 0 80

# broadcast emergency messages
? [= Level emergency] broadcast

# save kernel [PID 0] and launchd [PID 1] messages
? [<= PID 1] store

# save everything from emergency to notice
#? [<= Level notice] store
? [<= Level critical] store

# save lpr info level and above
#? [<= Level info] [= Facility lpr] store

# save all mail, ftp, local0, and local1 messages
#? [= Facility mail] store
#? [= Facility ftp] store
#? [= Facility local0] store
#? [= Facility local1] store
share|improve this answer
    
Welcome at SU. Yes, 50 reputation is needed, but there's more to know, so head over to superuser.com/faq right away! ;-) –  Arjan Sep 28 '09 at 10:38

Another tip might be helpful:

Change start up shell from default /usr/bin/login to /bin/bash -l, or /usr/bin/zsh if you use zsh.

That might make your Terminal/iTerm2 launch in light speed!

  • For Terminal: Preferences → Startup: Change from "Default login shell" to "Command: /bin/bash -l"

  • For iTerm2: Preferences → Profiles → General → Command: Change from "Login Shell" to "Command: /bin/bash -l"

share|improve this answer
1  
This sped up new tab loading considerably. –  Sindre Sorhus Sep 5 '12 at 4:00
    
Can't say how much this helped me. Solved ~6 months of slow terminal performance in 1 second. –  hatboysam Oct 21 '13 at 15:36
    
/bin/bash -l works for me! –  Phill Pafford Nov 25 '13 at 16:24
    
For those preferring to use the MacPorts bash: /opt/local/bin/bash -l –  johntex Dec 5 '13 at 0:08

A more permanent solution by editing sudo vi /etc/asl.conf is provided here.

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.