If the computer turns off unexpectedly, the shut down will not be detected. I won't update this for now unless someone actually wants to use this.
Simple python script to track your uptime on your computer and display it as a graph.
Example of graph generated after turning the computer on and off multiple times
Put the three python scripts in a single directory and make sure you have installed matplotlib (to install it, run pip install matplotlib
in a terminal)
Open Task Scheduler
, navigate to Task Scheduler (Local) > Task Scheduler Library
, and right click on Task Scheduler Library
. Click on Create Task
Change the group from your user to SYSTEM
Next, go to the Triggers
tab, click on New
, and choose At startup
Now you want to go to the Actions
tab, click on New
, and fill out the boxes like so:
Finally to avoid any issues, uncheck everything in the Conditions
tab.
Next, do the same thing, but by replacing uptimeCounterStart.bat
with uptimeCounterEnd.bat
, and changing the trigger to this:
The last step is to create your batch scripts that will run your python scripts.
uptimeCounterStart.bat
should look like this:
D:
cd D:\path\to\dir
py D:\path\to\dir\start.pyw
and uptimeCounterEnd.bat
should look like this:
D:
cd D:\path\to\dir
py D:\path\to\dir\end.pyw
Once you've done all that, it should work. To make sure it's working, restart your PC and check for a file called data.txt