You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Terminal或AppleScript控制风扇转速?实现无第三方工具的自动化调度

Hey there, let's break down how to control your Mac's fan speeds without relying on third-party apps first, then cover automation and scheduling with AppleScript. Here's what you need to know:

1. Native Terminal Control (No Third-Party Apps)

Mac's System Management Controller (SMC) handles fan regulation, and while there's no official built-in command to set exact speeds, you can interact with system tools to adjust behavior and monitor status:

  • Check current fan status: Use ioreg to read your fan's current speed, minimum, and maximum allowed values:

    ioreg -rn AppleSMC -k F0Ac -k F0Mn -k F0Mx
    

    (Note: F0 refers to the first fan—replace with F1, F2, etc., if you have multiple fans.)

  • Adjust thermal policy: Use pmset to tweak how aggressively the system triggers fan activation. Run this with sudo to apply changes globally:

    # Enable active cooling (fans kick in earlier)
    sudo pmset -a thermagent 1
    
    # Switch back to passive cooling (relies more on heat sinks)
    sudo pmset -a thermagent 0
    
2. AppleScript for Precise Fan Speed Control

If you need exact speed values, AppleScript can wrap shell commands to write directly to the SMC (works best on Intel Macs—Apple Silicon has stricter SMC restrictions):

Create a .scpt file with this code (adjust the fan speed and key as needed):

-- Set target fan speed (replace with a value between your fan's min/max)
set targetSpeed to 2200

-- Write to SMC (F0Ac = first fan control key; adjust to F1Ac for second fan, etc.)
do shell script "echo 'F0Ac " & targetSpeed & "' | sudo tee /dev/smc" with administrator privileges

When you run this, it'll prompt for your admin password—required to modify SMC settings.

3. Automation & Scheduling

To automate fan speed changes (e.g., ramp up during work hours, slow down at night), use these methods:

Create a plist file (e.g., com.yourusername.fancontrol.plist) and save it to ~/Library/LaunchAgents/:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.yourusername.fancontrol</string>
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>/path/to/your/fan-script.scpt</string>
    </array>
    <!-- Schedule to run at 10 AM daily -->
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>10</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <key>UserName</key>
    <string>your-actual-username</string>
    <key>RunAtLoad</key>
    <false/>
</dict>
</plist>

Load the job with:

launchctl load ~/Library/LaunchAgents/com.yourusername.fancontrol.plist

Option 2: Cron

For simpler scheduling, use cron:

  1. Open Terminal and run crontab -e to edit your cron jobs.
  2. Add a line like this to run your script at 10 AM daily:
    0 10 * * * osascript /path/to/your/fan-script.scpt
    
    (You'll need to set up passwordless sudo for the script if you don't want to be prompted every time—though this carries minor security risks.)

Important Notes

  • Apple Silicon Limitation: Apple Silicon Macs restrict direct SMC access more tightly; the above methods may not work as expected. Stick to pmset for thermal policy adjustments here.
  • Avoid Dangerous Speeds: Never set a speed lower than your fan's minimum (F0Mn from the ioreg command)—the system will override it anyway, and you risk overheating.
  • Admin Rights: All SMC-modifying commands need administrator privileges, so be cautious with automated scripts.

内容的提问来源于stack exchange,提问作者Kevin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:57:00