Automate Cleaning Of Terminal Logs

Have your Mac automatically clean its own Terminal .alp log files.

If you have have ever noticed Terminal can sometimes take a long time to start up, this is caused by .asl log files. Yeah, I don't what they are either.

You can remove them once by running:

sudo rm -f /private/var/log/asl/*.asl

But, that won't do you any good if you don't remember to do it regularly and it's a waste of time anyway.

You can automate this with cron but because this command requires sudo privelidges it has to be a run a different way. Luckily applescripts have the ability to execute terminal commands and ask for admin passwords.

Create an applescript file:

tell application "Terminal"
 do shell script "sudo rm -f /private/var/log/asl/*.asl" with administrator privileges
 quit
end tell

Put it in your crontab to run weekly or daily:

# On the 1st and 14th
0 21 1,14 * * osascript '/path/to/clean-terminal-logs.scpt' >/dev/null 2>&1
# Weekly
0 21 1,7,14,30 * * osascript '/path/to/clean-terminal-logs.scpt' >/dev/null 2>&1`

Whenever this runs, you will see a dialog asking for the admin password and thats it.

Now Terminal won't take 20 minutes to start up.