Make OS X Terminal Faster


Have you ever felt bored because the prompt of your Terminal is not immediately noticeable and you should to wait some moments when opening Terminal in your OS X? Some sources say the length of this process due to the writing of log files in OS X. To expedite the process, you can clean the log files. You can do it manually or by using a little trick. In this post, I will share the trick I mean.
  1. Open Terminal and enter the following commands (each command line should be ended by pressing ‘Enter’ button):
    cd /private/var/log/asl/
    ls *.asl
  2. From the second line command, you’ll see some files ending with .asl. If you do not find it, then I believe it is incorrect, repeat the above steps with a more cautious.
  3. Enter the command below (still you should complete the command by pressing ‘Enter’ button).
    sudo rm !$
  4. Enter your administrator password if asked.
  5. Quit the Terminal, and note the speed when you load it.
  6. Now, all you need to know is how to prevent your Terminal became slow again. Read the rest of this post.

How to prevent it?
  1. Open 'Finder'.
  2. Click on 'Go' > 'Go To Folder'.
  3. Type /etc and press the 'Enter' button.
  4. Find the asl.conf file.
  5. Use TextEdit to open the file above.
  6. If you get warn about the privilege, click Unlock.
  7. In the asl.conf file, go to the last line and enter three lines below:
    = archive 0
    = utmp_ttl 604800
    = fs_ttl 604800
    Explanation:
    • = archive 0 used to disable archiving the log.
    • = utmp_ttl used to sets the time-to-live for message. The number entered as a parameter is in units of seconds. 604800 = 7 days, so after 7 days the time-to-live parameter will be reached.
    • = fs_ttl used to sets the time-to-live for filesystem error. The parameter is in seconds too.
  8. Save the file, enter the Password if asked and close it.

Let's talk why the log makes Terminal running slow.
This is just an opinion, but I think the reason is quite reasonable.
  • Terminal will logs every commands entered to the ASLs (Apple System Logs). The ASL will be scanned to make command buffer so you can bring up previous commands by pressing the up/down arrow keys.
  • Last Login time stamp: When you open the Terminal, you may see the Last Login time at the top of the Terminal window. We assume that the Terminal scan the log files to gather this info and thus make the Terminal consume more time to scan when the log files grow. When checking the ASL's, this information is stored there.
  • The delay in this process does not mean there is something wrong with your Terminal, but it's related to the scanning process of the ASL's file. The Terminal will wait for the scanning process to complete before it displays the prompt.

Are the reasons above quite reasonable? Give your opinions. Hope it useful :)
Via proposedsolution.

No comments:

Post a Comment