Skip to content

Instantly share code, notes, and snippets.

@mypapit
Last active July 25, 2025 03:50
Show Gist options
  • Select an option

  • Save mypapit/01770a1fa47826db1f50caf45f6a9035 to your computer and use it in GitHub Desktop.

Select an option

Save mypapit/01770a1fa47826db1f50caf45f6a9035 to your computer and use it in GitHub Desktop.
#!/bin/bash
# semi-automatic script to check nvidia gpu temperature, and then trigger the fan for 15 minutes.
# intended to run within other scripts or in crontab
# Query GPU temperature
export DISPLAY=:0
TEMP=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits)
echo "$TEMP"
# Check if TEMP is greater than 60
if [ "$TEMP" -gt 60 ]; then
# Set fan control to manual and fan speed to 30%
nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=30
# Wait for 15 minutes (900 seconds)
sleep 900
# Restore fan control to automatic
nvidia-settings -a GPUFanControlState=0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment