Speed up a slow Terminal by clearing log files
Command Line, Mac OS X - May 6th, 2010 - 16 Comments
The Mac OS X Terminal can become slow to launch over time, but there’s an easy solution to speed it up again. By deleting the Apple System Logs, you can shave the lag in opening and launching new Terminal windows/tabs dramatically, in my case from about a three second delay to instantaneous!
Here’s how to delete the log files and gain your Terminal launch speed back:
At the command line type the following:
cd /private/var/log/asl/
then, inside that directory, type:
sudo rm -rf *.asl
Warning: be absolutely certain that you only type the sudo rm -rf command INSIDE the /var/log/asl/ directory! rm -rf * deletes all files in a directory, no questions asked, so if you perform that task in the wrong directory (like home folder) you are going to have a serious problem! I’m assuming you have moderate experience in the command line environment – if you do not, you probably won’t need this tip anyway.
Update: As Marc points out in the comments, it’s safer to specify deleting only the log files. Above command has been altered to reflect this. An alternative and shorter command is this one:
sudo rm -rf /private/var/log/asl/*.asl



just turning it into one long command might make it easier:
sudo rm -rf /private/var/log/asl/*
rm is dangerous for newbs
Thanks now my terminal ist much faster.
Before it needed 5-10 sek to load everything.
You could also make it a much safer tip by specifying *.asl
All of the logs, and nothing but the logs, would still be removed.
hey is it -rf or f in the command you say f* and then in the warning you are saying rf* so which one is it?
the -r flag specifies removing directories contained within as well, -f just forces the removal of the files without prompting and regardless of the file permissions.
The command can be:
sudo rm -f /private/var/log/asl/*.asl
Putting it all in one line and making it safer by specifying only *.asl files (logs) but this will not remove the directories contained within.
- Manish
new command is much better thank you
Thanks. That helped. Being a unix guy, I didn’t think I needed to do manual log file maintenance on OS X.
This worked great. Thanks!
@Scott: they might eventually get cleaned up like on any other unix box, but if your machine isn’t on all the time the cleanup scripts might never execute.
Thanks, this was driving me nuts. Problem solved.
BTW, my machine is on all the time, so apparently these particular files never do get cleaned up automatically.
Hey, when i did it, it said wrong command and it will be reported or sompin like that the reported thing kinda scared me whats that all about?
I believe you’re talking about the following message:
(username) is not in the sudoers file. This incident will be reported.
This means that your account is not an administrator account, and you cannot remove the files. You will have to run the command in an administrator account.
This worked like a charm. Thanks!
Unfortunately, within a week or so, the terminal is slow again. Would really prefer not to have to run this every week.
If you want to automatically run this script every once in a while, you can use cron jobs. Here are instructions to run the script every other hour. If you want to change how often it runs, I’d read more about cron jobs on the internet.
In terminal, type:
sudo env EDITOR=nano crontab -e
This will open the crontab file. Add the following to it:
0 */2 * * * rm -rf /private/var/log/asl/*.asl >/dev/null 2>&1
Save the file by pressing Control + X. Then, press y, and then enter.
After looking on the internet more, it seems 0 */2 * * * runs every two hours, and 0 0-23/2 * * * will run it every other hour. I can’t figure out what the difference is, but I just thought I would add that…
[...] this article, which fixed the issue, immediately. Nicely [...]