Check Maintenance Scripts On Your Mac 6

Tip

Check Maintenance Scripts On Your Mac

Hey

Sorry for the lack of posts over the last couple of days University has been really busy. Anyway today I am going to take to you about the maintenance scripts that your Mac runs. Every day, week and month your Mac runs a script to keep it healthy and hopefully running. These scripts are quite easy to locate and I am going to take to you about how they run, and if needs be if you need to change the time in which they run.

There are three main scripts that you Mac runs, daily, weekly and monthly. They take care of cleaning out log files, junk files and scratch files. The weekly script takes care of log files which don’t need to be deleted daily. The monthly files runs along the same lines. To check that they have run open up Terminal and type:

ls -al /var/log/*.out

You should see an output similar to the one below.

-rw-r--r--  1 root  wheel  271239 15 Mar 04:30 /var/log/daily.out
-rw-r--r--  1 root  wheel     906  1 Mar 06:50 /var/log/monthly.out
-rw-r--r--  1 root  wheel    4200 13 Mar 06:50 /var/log/weekly.out

If you have found that they haven’t run you can type (again in Terminal) the following:

sudo periodic daily weekly monthly

or

sudo periodic daily

were you can replace daily with weekly or monthly.

Normally these scripts run at round 3:15 in the morning. However if your Mac is shut down or asleep it wont run. So it may be worth changing this time. To do this you need to edit the LaunchDaemon which is responsible for running the scripts. These are located in /System/Library/LaunchDaemons and are called com.apple.periodic-daily.plist, com.apple.periodic-weekly.plist and com.apple.periodic-monthly.plist if you open up the file you will notice there is a couple of lines or specific code, such as the following found in the daily file.

<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>

This sets the daily file to run at 3:15am. You could change this file to something like 17:20, so it runs in the evening. I do however have reason to believe that the LaunchDaemon protocol counter only runs when your Mac is awake. So you may find that the script runs at random time and setting the values differently may cause them not to run at all. A solution to this is to keep your Mac awake (using an app such as Caffeine) on the first day of the month and every Saturday.

Hopefully you have understood the way the maintenance scripts work. The only variable in this little experiment is when they run as the LaunchDaemon process doesn’t run off system time, rather its own time. I will try and do a bit more testing in this area over the next couple of days and if I have anything conclusive i’ll update this post.

If you have any questions or comments, please leave one below.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

6 Responses to “Check Maintenance Scripts On Your Mac”

  1. 1

    James, nice post! I like your handy posts, especially when they revolve around the Terminal or more “power-user”-esque type hints.

    One thought: I would stop saying “Sorry for the lack of posts” or similar comments at the beginning of some posts. It’s not like anyone’s holding you to deadlines, but when read it only highlights the fact that it might have been a while since the last post. Most of us are just happy to get the posts, and not as concerned about frequency. Thanks, and keep it up!

    Comment By Joshua on March 15th, at 8:20 pm

  2. 2

    Hi James. I use a free Program called MacJanitor every day.Check it out. Also there are many free programs such as Onyx that does the daily, weekly and monthly scripts. Thanks and have a nice day.
    ken

    Comment By Kenneth John on March 16th, at 1:21 pm

  3. 3

    Many Thanks for usefully article.

    Comment By Shady on March 16th, at 3:33 pm

  4. 4

    Thanks for the tip on maintenance scripts. It seems mine run very rarely due to the time settings, as you predicted. However, having used Textedit to alter the time, I don’t have permission to save the change. I changed “sharing & permissions” privileges to Read & Write for admin, Me and system, but no luck.
    Any ideas?

    Comment By Paul Leese on March 16th, at 6:56 pm

  5. 5

    what about os x’s defrag script how does one invoke that of demand… would you care to share that knowledge if you possess it?

    Comment By adarkenigma on May 3rd, at 3:14 am

  6. 6

    Question- my daily.out file is ballooning beyond 4.6GB. Any way of finding out why/limiting the size of this file? -thx.

    Comment By greg on June 30th, at 8:16 pm

Leave a Reply

You can use: <a href> <h1 - h6> <acronym> <code> <em> <strike> <strong> <i> <b>