-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSYS-WIN.USAGE.RPT.py
41 lines (41 loc) · 2.35 KB
/
SYS-WIN.USAGE.RPT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#-- !/usr/bin/env python3
#-- -*- coding: utf-8 -*-
#--
#-- ************************************************************************************************************:
#-- ***************************************** RETRIEVE DAILY WIN USAGE *****************************************:
#-- ************************************************************************************************************:
#-- Author: JBallard (JEB) :
#-- Date: 2023.9.14 :
#-- Script: SYS-WIN.USAGE.RPT.py :
#-- Purpose: A Python script that retrieves the daily usage of your WIN system. :
#-- Class: python -m pip install time :
#-- Class: python -m pip install datetime :
#-- Version: 1.0 :
#-- ************************************************************************************************************:
#-- ************************************************************************************************************:
#--
#-- ********************************************************:
#-- DEFINE PARAMS, CONSTANTS, CONFIG PATHS, CLASSES, & LIBS :
#-- ********************************************************:
import time
from datetime import datetime
#--
#-- FUNCTION - RETRIEVE DAILY WIN USAGE:
def WINUSAGERpt():
#--
#-- LOG USAGE EVERY MIN:
with open('SYS-WIN.USAGE.RPT.jeb', 'a') as log:
start_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log.write(f"Computer started at {start_time}\n")
try:
while True:
time.sleep(60)
except KeyboardInterrupt:
end_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log.write(f"Computer shutdown at {end_time}\n")
#--
WINUSAGERpt()
#--
#-- ********************************************************:
#-- END OF PYTHON SCRIPT :
#-- ********************************************************: