-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
313 lines (300 loc) · 10.9 KB
/
Copy pathindex.html
File metadata and controls
313 lines (300 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mac Optimizer Pro — Advanced macOS Cleanup & Maintenance Script</title>
<meta name="description" content="Mac Optimizer Pro (optimize_pro.sh) is a free open-source bash script that cleans and tunes up macOS in one run: cache cleanup, RAM purge, DNS flush, Time Machine snapshot cleanup, Homebrew maintenance, Spotlight reindexing, and a disk check.">
<meta name="keywords" content="macOS optimization script, mac cleanup script, mac maintenance script, bash script macOS, homebrew maintenance, spotlight reindex, time machine snapshot cleanup, free up disk space mac, macOS performance">
<meta name="author" content="GridBoy">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://gridboy.github.io/script_optimize_mac/">
<meta property="og:type" content="website">
<meta property="og:title" content="Mac Optimizer Pro — Advanced macOS Cleanup & Maintenance Script">
<meta property="og:description" content="A free, open-source bash script that gives your Mac a deep clean and tune-up in one run — caches, RAM, DNS, Time Machine, Homebrew, Spotlight, and disk health.">
<meta property="og:url" content="https://gridboy.github.io/script_optimize_mac/">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Mac Optimizer Pro — Advanced macOS Cleanup & Maintenance Script">
<meta name="twitter:description" content="A free, open-source bash script that gives your Mac a deep clean and tune-up in one run.">
<style>
:root {
color-scheme: light dark;
--bg: #f7f7f8;
--surface: #ffffff;
--text: #1c1c1f;
--muted: #5b5b63;
--border: #e2e2e6;
--accent: #0060df;
--ok: #1a7f37;
--warn: #9a6700;
--danger: #cf222e;
--code-bg: #f0f1f3;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #16161a;
--surface: #1e1e23;
--text: #eceef0;
--muted: #a3a3ad;
--border: #303038;
--accent: #6fa8ff;
--ok: #4cbb6b;
--warn: #e0a83a;
--danger: #f2777a;
--code-bg: #26262d;
}
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
line-height: 1.55;
}
main {
max-width: 860px;
margin: 0 auto;
padding: 2.5rem 1.5rem 5rem;
}
header h1 {
font-size: 1.9rem;
margin-bottom: 0.25rem;
}
header p.subtitle {
color: var(--muted);
margin-top: 0;
font-size: 1.05rem;
}
.badge-row {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin: 1rem 0 2rem;
}
.badge {
font-size: 0.78rem;
font-weight: 600;
padding: 0.25rem 0.6rem;
border-radius: 999px;
border: 1px solid var(--border);
color: var(--muted);
}
.callout {
border: 1px solid var(--border);
border-left: 4px solid var(--accent);
background: var(--surface);
border-radius: 8px;
padding: 1rem 1.2rem;
margin: 1.5rem 0 2.5rem;
}
.callout strong { color: var(--accent); }
h2 {
font-size: 1.3rem;
margin-top: 3rem;
padding-bottom: 0.4rem;
border-bottom: 1px solid var(--border);
}
.step {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.2rem 1.4rem;
margin: 1.1rem 0;
}
.step-head {
display: flex;
align-items: baseline;
gap: 0.6rem;
margin-bottom: 0.4rem;
}
.step-num {
font-variant-numeric: tabular-nums;
color: var(--accent);
font-weight: 700;
font-size: 0.95rem;
}
.step-title {
font-weight: 600;
font-size: 1.05rem;
}
.step p {
margin: 0.5rem 0;
color: var(--text);
}
.step .meta {
color: var(--muted);
font-size: 0.9rem;
}
code, pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.88em;
}
code {
background: var(--code-bg);
padding: 0.15em 0.4em;
border-radius: 4px;
}
pre {
background: var(--code-bg);
padding: 0.9rem 1rem;
border-radius: 8px;
overflow-x: auto;
margin: 0.6rem 0;
}
pre code { background: none; padding: 0; }
.risk {
display: inline-flex;
align-items: center;
gap: 0.3rem;
font-size: 0.8rem;
font-weight: 600;
padding: 0.15rem 0.5rem;
border-radius: 6px;
margin-left: 0.4rem;
}
.risk.low { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.risk.med { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.risk.high { color: var(--danger); background: color-mix(in srgb, var(--danger) 15%, transparent); }
footer {
margin-top: 3.5rem;
padding-top: 1.2rem;
border-top: 1px solid var(--border);
color: var(--muted);
font-size: 0.85rem;
}
a { color: var(--accent); }
</style>
</head>
<body>
<main>
<header>
<h1>⚡ Mac Optimizer Pro</h1>
<p class="subtitle">Give your Mac a deep clean and tune-up, automated. Here's exactly what <code>optimize_pro.sh</code> does, step by step.</p>
<div class="badge-row">
<span class="badge">Bash</span>
<span class="badge">macOS</span>
<span class="badge">Free & open-source</span>
<span class="badge">Requires sudo</span>
<span class="badge">GPL-3.0</span>
</div>
</header>
<div class="callout">
<strong>🧰 Good to know.</strong> This script goes deep, so a few steps
clear things out for good (caches, logs, local Time Machine snapshots) —
the same cleanup a power user would do by hand, just automated. As with
any system maintenance, it's good practice to have a recent backup on
hand. See the <a href="../README.md">README</a> for usage instructions.
</div>
<h2>Overview</h2>
<p>
<code>optimize_pro.sh</code> runs eight maintenance functions in
sequence. After the user confirms, the script asks for the administrator
password once (<code>sudo -v</code>) and then keeps the <code>sudo</code>
session alive in the background for the whole run, so it doesn't prompt
again at every step.
</p>
<h2>Procedure details</h2>
<div class="step">
<div class="step-head">
<span class="step-num">1</span>
<span class="step-title">clean_caches — Cache cleanup</span>
<span class="risk med">Moderate impact</span>
</div>
<p>Removes the contents of system and user cache directories, and application log files.</p>
<pre><code>sudo rm -rf /Library/Caches/*
rm -rf ~/Library/Caches/*
rm -rf ~/Library/Logs/*</code></pre>
<p class="meta">Effect: frees disk space and forces applications to rebuild their caches on next launch (may slow their first startup).</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">2</span>
<span class="step-title">clean_temp_files — System temporary files</span>
<span class="risk low">Light touch</span>
</div>
<p>Empties the temporary file directories used by the system and applications.</p>
<pre><code>sudo rm -rf /private/var/tmp/*
sudo rm -rf /private/var/folders/*</code></pre>
<p class="meta">Effect: purges volatile files that are normally recreated on demand.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">3</span>
<span class="step-title">purge_ram — RAM purge</span>
<span class="risk low">Light touch</span>
</div>
<p>Forces macOS to release inactive memory pages.</p>
<pre><code>sudo purge</code></pre>
<p class="meta">Effect: may temporarily slow down the system while memory caches are rebuilt.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">4</span>
<span class="step-title">flush_dns — DNS cache</span>
<span class="risk low">Light touch</span>
</div>
<p>Flushes the DNS resolver cache and restarts the resolver service.</p>
<pre><code>sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder</code></pre>
<p class="meta">Effect: the next domain name lookups will be resolved from scratch.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">5</span>
<span class="step-title">clean_time_machine_snapshots — Local Time Machine snapshots</span>
<span class="risk high">Frees the most space</span>
</div>
<p>Lists and then deletes local snapshots created by Time Machine (restore points stored on the internal disk).</p>
<pre><code>tmutil listlocalsnapshots /
sudo tmutil deletelocalsnapshots <snapshot></code></pre>
<p class="meta">Effect: frees the disk space used by these snapshots. Does not delete Time Machine backups on an external drive, but reduces the local restore points available.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">6</span>
<span class="step-title">maintain_homebrew — Homebrew maintenance</span>
<span class="risk med">Moderate impact</span>
</div>
<p>If Homebrew is installed, updates formulae, upgrades installed packages, removes orphaned dependencies, and cleans the cache.</p>
<pre><code>brew update
brew upgrade
brew autoremove
brew cleanup -s</code></pre>
<p class="meta">Effect: Homebrew packages are upgraded to their latest versions; the step is skipped if <code>brew</code> is not detected.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">7</span>
<span class="step-title">reindex_spotlight — Spotlight reindexing</span>
<span class="risk med">Moderate impact</span>
</div>
<p>Forces a full rebuild of the Spotlight search index for the main volume.</p>
<pre><code>sudo mdutil -E /</code></pre>
<p class="meta">Effect: Spotlight search may be temporarily unavailable or incomplete, and CPU usage may increase for several minutes while reindexing runs in the background.</p>
</div>
<div class="step">
<div class="step-head">
<span class="step-num">8</span>
<span class="step-title">repair_disk_permissions — Disk verification</span>
<span class="risk low">Light touch</span>
</div>
<p>Checks the integrity of the boot volume's file system.</p>
<pre><code>diskutil verifyVolume /</code></pre>
<p class="meta">Effect: read-only operation (verification, not automatic repair); may take several minutes.</p>
</div>
<h2>Confirmation and completion</h2>
<p>
Before starting, the script displays a warning and asks for explicit
confirmation (<code>o</code>/<code>n</code>, French for yes/no). After the eight steps
complete, it recommends restarting the machine
(<code>sudo shutdown -r now</code>) to fully apply the effects of the
maintenance.
</p>
<footer>
See the repository <a href="../README.md">README</a> for usage and the
<a href="../CONTRIBUTING.md">contributing guide</a>.
</footer>
</main>
</body>
</html>