yeonghoon.kim

  • 게시판
  • 갤러리
  • aws

파이썬 디스크 용량 체크

김영훈 2023.01.04 11:37 조회 수 : 449

#!/usr/bin/python3.9

import shutil

 

# 1. 체크할 디스크 파티션 지정 후 결과값 변수에 저장

diskLabel = '/'

 

total, used, free = shutil.disk_usage(diskLabel)

totalGB = round((total / 1024 / 1024 / 1024), 2)

usedGB = round((used / 1024 / 1024 / 1024), 2)

freeGB = round((free / 1024 / 1024 / 1024), 2)

freePercent = round(((free / total) * 100), 2)

 

msg = "total: " + str(totalGB) + "GB, free: " + str(freeGB) + "GB(" + str(freePercent) + "%)"

print(msg)


  • 추천 0

  • 비추천 0
이 게시물을
목록

댓글 0

사진 및 파일 첨부

여기에 파일을 끌어 놓거나 왼쪽의 버튼을 클릭하세요.

파일 용량 제한 : 0MB (허용 확장자 : *.*)

업로드 중... (0%)

0개 첨부 됨 ( / )
 
번호 제목 글쓴이 날짜 조회 수
공지 2025 일본 여행 계획 김영훈 2024.10.10 985
공지 현금, 저축, 투자, 지출, 예산, 보험 내역(2024-05-30) 김영훈 2024.03.10 638
225 시스템프로그래밍 2주차 - 사용명령 김영훈 2023.03.08 277
224 Python cx_Oracle 모듈 샘플코드 김영훈 2023.03.03 328
223 아이맥 화면 동영상 캡처 - 커맨드 + 쉬프트 + 5 김영훈 2023.02.28 239
222 paramiko 일괄 명령 테스트 김영훈 2023.01.05 332
» 파이썬 디스크 용량 체크 김영훈 2023.01.04 449
220 Uptime Kuma용 push(패시브) 체크용 파일.py [1] 김영훈 2022.12.21 310
219 python - re 라이브러리 김영훈 2022.12.19 341
218 python - requests 라이브러리 김영훈 2022.12.19 260
217 python - socket 라이브러리 김영훈 2022.12.19 349
216 python - random 라이브러리 김영훈 2022.12.19 300
215 CentOS7 아나콘다 환경에 주피터 노트북 설치 김영훈 2022.12.03 652
214 CentOS7 - minikube 설치 김영훈 2022.12.02 395
213 growpart - no tools available to resize disk with 'gpt' 김영훈 2022.12.01 271
212 mac homebrew 설치 김영훈 2022.11.30 219
211 centos7 gitlab 설치 김영훈 2022.11.28 327
210 Your account is pending approval from your GitLab administrator and hence blocked. Please contact your GitLab administrator if you think this is an error. 김영훈 2022.11.28 451
209 mac에서 centos6 ssh 접속 시 오류 - no matching host key type found. Their offer: ssh-rsa,ssh-dss 김영훈 2022.11.27 386
208 Centos Console 화면 보호기 setterm 김영훈 2022.11.26 220
207 CentOS8-Stream packstack 설치 [5] 김영훈 2022.11.24 401
206 CentOS7 EUC-KR 로케일 설정 김영훈 2022.10.20 289
쓰기 태그
 첫 페이지 1 2 3 4 5 6 7 8 9 10 끝 페이지