yeonghoon.kim

  • 게시판
  • 갤러리
  • aws

파이썬 디스크 용량 체크

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

#!/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

번호 제목 글쓴이 날짜 조회 수
공지 2025 일본 여행 계획 김영훈 2024.10.10 3271
공지 현금, 저축, 투자, 지출, 예산, 보험 내역(2024-05-30) 김영훈 2024.03.10 2826
» 파이썬 디스크 용량 체크 김영훈 2023.01.04 1258
48 paramiko 일괄 명령 테스트 김영훈 2023.01.05 1374
47 아이맥 화면 동영상 캡처 - 커맨드 + 쉬프트 + 5 김영훈 2023.02.28 497
46 Python cx_Oracle 모듈 샘플코드 김영훈 2023.03.03 2110
45 시스템프로그래밍 2주차 - 사용명령 김영훈 2023.03.08 763
44 데이터베이스 2주차 - 실습 김영훈 2023.03.08 827
43 python csv 파일 읽은 후 엑셀 파일로 저장 샘플 김영훈 2023.03.16 1866
42 데이터베이스 3주차 실습 김영훈 2023.03.19 885
41 Sectigo PositiveSSL 신청 시 파일 - 20230512 기준 [1] file 김영훈 2023.05.12 1280
40 [Bard] node.js forever 사용법 알려줘 김영훈 2023.05.18 1070
39 SAP_1. Identity & Federation Section 김영훈 2023.06.13 709
38 rockylinux kvm [1] 김영훈 2023.07.12 1132
37 FCM 푸시 보내기 - pyfcm 김영훈 2023.07.20 1572
36 FCM 푸시보내기 - firebase_admin 김영훈 2023.07.20 1787
35 let's encrypt 와일드카드 인증서 발급 (CentOS7) [2] 김영훈 2023.07.26 923
34 2학기 수강신청 김영훈 2023.08.01 646
33 pyapns_client 동시에 여러 기기로 푸시 보내기 김영훈 2023.08.03 746
32 geoip2 python [1] 김영훈 2023.08.10 1277
31 삼성 스마트태그 배터리 - CR2032 김영훈 2023.08.15 529
30 iptables ip 포워딩 [1] 김영훈 2023.08.17 1142
쓰기 태그
 첫 페이지 5 6 7 8 9 10 11 12 13 14 끝 페이지