tempcg is a simple script to monitor and display the CPU and GPU temperatures directly in the terminal. With the command tempcg, you can easily check your system's temperature in real-time, making it ideal for users who want quick access to critical hardware information without opening additional monitoring software.
این پروژه شامل یک اسکریپت است که دمای CPU و GPU سیستم شما را در ترمینال نمایش میدهد. شما میتوانید با وارد کردن دستور tempcg در ترمینال، اطلاعات دما را بهصورت خودکار مشاهده کنید.
-
ایجاد اسکریپت:
- ابتدا یک فایل به نام
tempcg.shایجاد کرده و کد زیر را در آن وارد کنید:watch -n 1 "echo '------ CPU Temperature: ------' && sensors | grep 'Core' && echo '\n------ GPU Information: ------' && nvidia-smi --query-gpu=pci.bus_id,name,temperature.gpu,utilization.gpu --format=csv,noheader && echo '\n___ Script by Mohammad Hossein Soleymani ___'" - سپس فایل را ذخیره کرده و به آن مجوز اجرایی بدهید:
chmod +x ~/tempcg.sh
- ابتدا یک فایل به نام
-
اضافه کردن دستور tempcg به bashrc:
- برای اینکه دستور
tempcgاجرا شود، باید این نام دستور را در فایل~/.bashrcثبت کنید. انتهای فایل~/.bashrcخط زیر را اضافه کنید:alias tempcg="~/tempcg.sh"
- سپس تغییرات را با استفاده از دستور زیر بارگذاری کنید:
source ~/.bashrc
- برای اینکه دستور
-
تست دستور:
- حالا میتوانید با وارد کردن دستور
tempcgدر ترمینال، دمای CPU و GPU را مشاهده کنید.
- حالا میتوانید با وارد کردن دستور
- فایل
~/.bashrcبه تنظیمات ترمینال شما تعلق دارد و با هر بار باز کردن ترمینال بارگذاری میشود. - این اسکریپت هر ثانیه یک بار اطلاعات دما را بهروز میکند.
This project includes a script that displays your system's CPU and GPU temperatures in the terminal. By entering the tempcg command, you can automatically view temperature data.
-
Create the Script:
- First, create a file named
tempcg.shand add the following code:watch -n 1 "echo '------ CPU Temperature: ------' && sensors | grep 'Core' && echo '\n------ GPU Information: ------' && nvidia-smi --query-gpu=pci.bus_id,name,temperature.gpu,utilization.gpu --format=csv,noheader && echo '\n___ Script by Mohammad Hossein Soleymani ___'" - Then, save the file and make it executable:
chmod +x ~/tempcg.sh
- First, create a file named
-
Add tempcg Command to bashrc:
- To make the
tempcgcommand available in your terminal, add the following line at the end of your~/.bashrcfile:alias tempcg="~/tempcg.sh"
- Then, load the changes using the command:
source ~/.bashrc
- To make the
-
Test the Command:
- Now, by entering the
tempcgcommand in the terminal, you will be able to see the CPU and GPU temperatures.
- Now, by entering the
- The
~/.bashrcfile is part of your terminal settings and is loaded each time you open the terminal. - The script refreshes the temperature data every second.