Check Maintenance Scripts On Your Mac 8

Tip

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

Where To Next?

  • Subscribe To Mac Tricks And Tips