9.2 Make Your Own Schedule Script
A schedule script is actually a text file, and you can use any text editor to create and edit it.
Below is a very simple schedule script and it will keep your Raspberry Pi on for 5 minutes in every 20
minutes.
Like many other scripting languages, Witty Pi’s schedule script also uses “#” to make single line
comment.
The first two lines define the time range for executing the script. Please make sure to use the correct
time format (YYYY-mm-DD HH:MM:SS). You can use one or more white characters (space or tab)
between BEGIN/END and the time string.
The rest of the script defines the states in the loop. It could be “ON” or “OFF”, and you should define
at least one “ON” and one “OFF” states in the loop. The ON and OFF states are used in pair.
You should also specify the duration of each state. You can do so by putting one or more parameters
after ON/OFF text, separated by space or tab. Each parameter starts with a capital letter and follows
by a number, where the capital letter is the unit of time:
D = Days (D2 means 2 days)
H = Hours (H3 means 3 hours)
M = Minutes (M15 means 15 minutes)
S = Seconds (S30 means 30 seconds)
For example, if you wish to define an ON state for one and a half hours, you can write:
ON H1 M30
When the script engine executes this line, it will schedule a shutdown at the end of the ON state.
If you wish to define an OFF state for two days, you can write:
OFF D2
When this line gets executed, a startup will be scheduled at the end of the OFF state.
# Turn on Raspberry Pi for 5 minutes, in every 20 minutes
BEGIN 2021-08-01 00:00:00
END 2025-07-31 23:59:59
ON M5 # keep ON state for 5 minutes
OFF M15 # keep OFF state for 15 minutes