Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python
- # This script runs once a minute via crontab. /media/NETWRK is a router-attached network drive mounted at startup.
- # Since the 5yo 2TB WD tends to spin down every 90 seconds or so, this simply pings it once a minute to keep it active.
- # Settings allow sleep periods during certain hours of the day and days of the week where the drive will probably not be in use.
- import datetime as dt
- import sys
- Enabled=1
- WeekDays = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
- SleepStart = 23
- SleepEnd = 6
- SleepDays = ["Saturday","Sunday"]
- Filename = "/media/NETWRK/tmp.txt"
- if not Enabled:
- # print("Terminated by enable")
- sys.exit()
- Hour = dt.datetime.today().hour
- DOW = dt.datetime.today().weekday()
- # print(str(Hour) + ", " + str(DOW))
- if SleepStart > SleepEnd:
- if Hour > SleepStart or Hour < SleepEnd:
- # print("Terminated by Sleep")
- sys.exit()
- else:
- if Hour > SleepStart and Hour < SleepEnd:
- # print("Terminated by Sleep")
- sys.exit()
- for w in SleepDays:
- if WeekDays[DOW] == w:
- # print("Terminated by DOW")
- sys.exit()
- # print("Got here!")
- f = open(Filename,"w")
- f.write("Temporary String " + str(dt.datetime.now()))
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement