41

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?

2

8 Answers 8

41

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

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

This did the trick for me.

8
  • 3
    (ASL = Apple System Log)
    – Arjan
    Sep 28, 2009 at 8:55
  • +1. Worked like a charm even though as one of the other answers suggested I have a non-trivial .bashrc.
    – alesplin
    Feb 5, 2011 at 20:48
  • 7
    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. Feb 24, 2011 at 12:34
  • 1
    Anyone have any idea why the size of system logs effect how fast the terminal opens? Aug 2, 2012 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.
    – Lri
    Aug 6, 2012 at 9:59
32

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"

9
  • 2
    This sped up new tab loading considerably. Sep 5, 2012 at 4:00
  • 1
    Can't say how much this helped me. Solved ~6 months of slow terminal performance in 1 second.
    – Sam Stern
    Oct 21, 2013 at 15:36
  • /bin/bash -l works for me! Nov 25, 2013 at 16:24
  • For those preferring to use the MacPorts bash: /opt/local/bin/bash -l
    – 0 _
    Dec 5, 2013 at 0:08
  • 1
    did this change break your theme? Jun 26, 2017 at 0:18
9

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
1
  • 1
    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, 2009 at 10:38
7

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.

2
1

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).

1
  • 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? Oct 25, 2011 at 13:45
1

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.

2
  • He said that the Terminal window was open which means the process has loaded. Aug 30, 2009 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, 2009 at 8:52
0

Open /etc/profile and add the line PATH="" so it looks like this:

if [ -x /usr/libexec/path_helper ]; then
    PATH=""
    eval `/usr/libexec/path_helper -s`
fi
0

If you are using oh my zsh with composer plugin, just remove it.(I'm running OSX 10.14 on a MacBookPro)

# .zshrc
plugins=(git) # composer will slow you down

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .