This code is used for a raspberry pi project. With this script I could monitor how long my raspberry pi would stay active on a 12 volt battery. The script is quite easy. It just picks up the time it started and then prints the current time every 5 minutes. The printed values are writting to a text file called running.txt.
1 2 3 4 5 6 7 8 9 10 11 |
import time def infinatecounter(x): start = "Started at "+time.asctime(time.localtime(time.time())) print start while x>0: f = open("running.txt", "w") f.write(start+'\r\n') f.write("Still active at "+time.asctime(time.localtime(time.time()))+'\r\n') f.close() time.sleep(300) #A 5 minute sleep |
Leave a Reply