What are maintenance scripts?
Mac’s OS X has a built-in function to keep your system from getting bogged down with old files that are no longer needed.
Every Mac has three versions of its maintenance scripts — daily, weekly, and monthly — that handle clearing out different unnecessary files as well as some additional system upkeep like reporting network statistics and rebuilding the so-called locate and whatis databases. Regular maintenance makes it easier to keep your Mac in top condition, rather than trying to resolve issues once they’ve already taken hold.
On older OS X versions Mac maintenance scripts used to be automatically scheduled to run at a certain time (03:15 for daily scripts, Saturday at 03:15 or 04:30 for weekly, and the first of the month at 05:30 for monthly). These are times when your Mac system expects to have a little down-time to get its housekeeping done.
Why run maintenance scripts? Can't Mac clean itself?
The arrival of macOS Sierra in 2016 introduced some self-cleaning features on the Mac. What was previously done by scheduled maintenance scripts is now performed by the macOS itself without you even knowing. This is what the macOS cleans automatically on your Mac:
- Apple-related cache
- Apple’s Temporary files
- Twin downloads in Safari
- Unused fonts, languages, and dictionaries
Nice progress, you say. Yes, but still that barely scratches the surface in terms of real system cleanup. What’s been left out is third-party cache, temporary browser files and all sorts of media. By the way, there are more than one Trash bin on your Mac (each app has its own trash folder) and they have too be cleaned as well. As a final clincher, here’s a fact: Places you viewed on Google Earth 4 months ago, are still there, deep down inside your Mac’s system folders.
A healthy way to use maintenance scripts
As we’ve seen even newer Macs need regular “under-the-hood” optimization to run well. There are dedicated apps that willtake the job off your shoulders. You can see Maintenance Scripts in action with CleanMyMac X. Launch the app (it has a free version), run the maintenance scripts tool and see how it affects your computer performance. This should rotate certain system logs, rearrange libraries and lots of other technical tasks known only to developers.
Next, we'll explain how to run Maintenance scripts manually, but if you want the job done and forgotten, run CleanMyMac X.
- Download it here (free download).
- Launch CleanMyMac.
- Click Maintenance > Run Maintenance scripts.
Or you can try the manual way, which might be exhausting and time consuming.
The default time for maintenance scripts assumes that there will be minimal if any interference to the Macs user during this period, which makes sense: whether working late or starting early, half past five in the morning isn’t peak productivity time.
But the thing is, when we switch off for the night we turn the Mac off completely. After all, we don’t want to waste money powering a computer while we’re sleeping or risk being disturbed by notifications. But if your Mac is turned off at the time scheduled for maintenance scripts, it will fail to run them, and chances are it will fail again the next morning and the morning after.
If the maintenance scripts aren’t getting the chance to run, old files and junk caches begin to build up and affect your system performance.
How to check when maintenance scripts were last run
Maybe you’re not sure when your Mac was last able to run the full trio of maintenance scripts. Maybe it’s been a while since it ran any at all. If you’d like to check, you will need to enter the Terminal application.
1. Use either the Spotlight application to search for Terminal, or navigate to its location by selecting Applications from the sidebar of a Finder window, from there selecting Utilities and then double-clicking on Terminal.
2. In the Terminal command bar, enter
ls -al /var/log/*.out
It’s important to enter the command exactly as above, including spaces.
3. Pressing Enter will bring up a list of when (date and a time) a maintenance script was run and what type of script it was (daily, weekly, or monthly). If the scripts are running automatically, you will see timestamps for their default times (03:15, 04:30, or 05:30).
If the logs are showing that your maintenance scripts haven’t been run for a while, it’s recommended that you run a manual script.
How to Run Maintenance Scripts through Terminal
We’ve already looked at how to use Terminal to check when a maintenance script was last performed by your OS, but you can also use it to manually run a maintenance script.
Note: you will need an administrator password to run maintenance scripts through Terminal.
1. Open Terminal either through the Spotlight search or by navigating to the Utilities folder in Applications.
2. In the Terminal command bar, enter
sudo periodic daily weekly monthly
3. Enter the above text. Press Return, and you will be asked to enter your administrator password. For security reasons, your password will not appear onscreen.
4. Your Mac will then perform three maintenance scripts. There won’t be a status bar or percentage to show that the scripts are being run, but you’ll know they’re complete when the Terminal prompt returns.
If you only want to perform one maintenance — perhaps you’ve missed your monthly script, or you have limited time – then you can edit the Terminal command to be simply sudo periodic monthly, which you should enter into the Terminal.
An alternative to manually running Maintenance Scripts on macOS
If typing code into Terminal seems a bit daunting, there is third-party software that can run a simple scan for you to clear out the junk, such as CleanMyMac. It offers a thorough system cleanup to keep your Mac running on only the files you need.
CleanMyMac X has a clear, easy to use interface to run maintenance scripts without going into Mac’s Terminal function. Simply select Maintenance from the left sidebar and from there you can select which maintenance tasks your system currently needs.
Or, if you just want to run a general scan, CleanMyMac’s Smart Scan quickly checks your Mac for files that are safe to remove, organizes them into categories (System Junk, Photo Junk, Mail Attachments, iTunes Junk, Trash Bins, and Large & Old Files) and tells you how much space you’ll save by deleting them. Scan your system and delete unused, forgotten files to free up data for system performance.
Download CleanMyMac X to handle your maintenance and keep your Mac running smoothly without the unnecessary bulk.