Monitor Jetson Orin Nano Temperature in Real-Time with a Bash Script
To monitor Jetson Orin Nano temperatures in a clean vertical format, create a Bash script that reads and parses the built-in tegrastats
output.
First, create a script file:
nano jetson-temp-monitor.sh
Paste the following:
#!/bin/bash
# Trap Ctrl+C to show cursor again and exit cleanly
trap "tput cnorm; exit" INT
# Hide the cursor for cleaner output
tput civis
# Start tegrastats and process its output line by line
tegrastats | while read -r line; do
clear # Clear the terminal screen on each update
# Extract temperature values using grep and Perl-compatible regex (-oP)
cpu_temp=$(echo "$line" | grep -oP 'cpu@\K[0-9.]+C')
gpu_temp=$(echo "$line" | grep -oP 'gpu@\K[0-9.]+C')
soc0_temp=$(echo "$line" | grep -oP 'soc0@\K[0-9.]+C')
soc1_temp=$(echo "$line" | grep -oP 'soc1@\K[0-9.]+C')
soc2_temp=$(echo "$line" | grep -oP 'soc2@\K[0-9.]+C')
tj_temp=$(echo "$line" | grep -oP 'tj@\K[0-9.]+C')
# Print the temperatures in a vertical format
echo "Jetson Orin Nano Temperature Monitor"
echo "------------------------------------"
echo "CPU Temp : ${cpu_temp:-N/A}"
echo "GPU Temp : ${gpu_temp:-N/A}"
echo "SoC0 Temp : ${soc0_temp:-N/A}"
echo "SoC1 Temp : ${soc1_temp:-N/A}"
echo "SoC2 Temp : ${soc2_temp:-N/A}"
echo "Tj Temp : ${tj_temp:-N/A}"
echo ""
echo "Press Ctrl+C to stop."
done
Save and exit. Then make it executable:
chmod +x jetson-temp-monitor.sh
Now just run it:
./jetson-temp-monitor.sh
It will display real-time temperature updates vertically. Press Ctrl+C
to stop.
Update on the Script
This version includes more information about the system.
#!/bin/bash
# === Cleanup on exit ===
cleanup() {
tput cnorm # Show cursor
stty echo # Re-enable terminal echo
clear # Optional: clear screen
exit
}
# Trap all common termination signals
trap cleanup INT TERM EXIT
# Hide cursor and disable terminal echo
tput civis
stty -echo
# Clear screen initially
clear
# Main loop from tegrastats
tegrastats | while read -r line; do
tput cup 0 0 # Move cursor to top-left
# Extract temperatures
cpu_temp=$(echo "$line" | grep -oP 'cpu@\K[0-9.]+C')
gpu_temp=$(echo "$line" | grep -oP 'gpu@\K[0-9.]+C')
soc0_temp=$(echo "$line" | grep -oP 'soc0@\K[0-9.]+C')
soc1_temp=$(echo "$line" | grep -oP 'soc1@\K[0-9.]+C')
soc2_temp=$(echo "$line" | grep -oP 'soc2@\K[0-9.]+C')
tj_temp=$(echo "$line" | grep -oP 'tj@\K[0-9.]+C')
# Extract GPU usage
gpu_usage=$(echo "$line" | grep -oP 'GR3D_FREQ \K[0-9]+%')
# Extract per-core CPU usage
cpu_raw=$(echo "$line" | grep -oP 'CPU\s*\[\K[^\]]+')
if [ -n "$cpu_raw" ]; then
cpu_usage_formatted=$(echo "$cpu_raw" | tr ',' '\n' | sed 's/@.*//' | paste -sd' | ' -)
else
cpu_usage_formatted="N/A"
fi
# Extract RAM usage
ram_usage=$(echo "$line" | grep -oP 'RAM \K[0-9]+/[0-9]+MB')
# Extract SWAP usage like "225/16384MB"
swap_usage=$(echo "$line" | grep -oP 'SWAP \K[0-9]+/[0-9]+MB')
# Display
echo "Jetson Orin Nano Monitor"
echo "-------------------------"
#echo "RAM Usage : ${ram_usage:-N/A} "
echo "CPU Temp : ${cpu_temp:-N/A} "
echo "GPU Temp : ${gpu_temp:-N/A} "
echo "SoC0 Temp : ${soc0_temp:-N/A} "
echo "SoC1 Temp : ${soc1_temp:-N/A} "
echo "SoC2 Temp : ${soc2_temp:-N/A} "
echo "Tj Temp : ${tj_temp:-N/A} "
echo ""
echo "CPU Usage : ${cpu_usage_formatted} "
echo "GPU Usage : ${gpu_usage:-N/A} "
echo "RAM Usage : ${ram_usage:-N/A} "
echo "SWAP Usage : ${swap_usage:-N/A} "
echo ""
echo "Press Ctrl+C to stop. "
done
Output Result
Jetson Orin Nano Monitor
-------------------------
CPU Temp : 63.687C
GPU Temp : 64.375C
SoC0 Temp : 62.218C
SoC1 Temp : 62.75C
SoC2 Temp : 62C
Tj Temp : 64.375C
CPU Usage : 4% 1%|3% 30% 1%|43%
GPU Usage : 41%
RAM Usage : 5202/7620MB
SWAP Usage : 217/16384MB
Press Ctrl+C to stop.