GRUB 2 has outsourced many functions into modules. This makes it possible to load only the required functions and thus smaller core images are possible. You can also use these modules to extend GRUB, e.g. to implement scheduling in GRUB. This makes it possible to start an particular operating system at a certain time.
You get a list of all available modules with
$ ls /boot/grub/i386-pc/
Configuring Scheduling in GRUB
For the scheduling in GRUB you need the module
datehook. This allows access to the following variables in GRUB:
All these values are based on the time and date set in the BIOS (usually the mainboard hardware clock). You have to keep that in mind when setting up the scheduling in GRUB.
With the following command you get a list with all menu items of the GRUB menu:
$ grep -E '^menuentry|^submenu' /boot/grub/grub.cfg | cut -d '"' -f2 | cut -d "'" -f2
The first entry has the number 0, the second the number 1 and so on.
Next open the file /boot/grub/grub.cfg and add the following lines relative to the beginning of the file:
# Add an extra zero for minute 0-9, so MINUTE is always double-digit
if[ $MINUTE -lt 10 ]; then PADDING="0"; else PADDING="""; fi
# Start Ubuntu by default
# Start Windows 10 from 5:00 p.m. to 11:00 p.m.
if[ $TIME -ge 1700 -a $TIME -lt 2300 ]; then
At the beginning, an extra zero is inserted for minutes smaller than 10, so that the number of minutes is always two digits. Then we construct a new variable
TIME, which has the current time in the format HHMM. These can now be used to implement scheduling in GRUB.
Ubuntu should be started by default, but in the evening Windows 10 takes precedence. It may be necessary to adjust the times, since the time zone UTC is often set up in the BIOS.
The changes above are only valid until the next time
update-grub is executed. To keep the changes in GRUB permanently, you should create a template with this code in /etc/grub.d/.
We use this option to better manage our computers at school. Ubuntu is started by default during the day, but during the night we let Linbo boot so that the computers can be updated or provided with a new image, for example.