How can I run specific commands during the boot process?

Create or edit the /etc/rc.local file and add the appropriate commands. Here is an example using the vim editor.

sudo vim /etc/rc.local
chmod 755 /etc/rc.local

After a reboot, the Redis cache should be cleared and the Neos node index should be built:

#!/bin/sh

/usr/local/bin/redis-cli flushall
/usr/bin/su -m proserver -c "FLOW_CONTEXT=Production/Live /usr/local/bin/php /var/www/neos/flow nodeindex:build --workspace live"

Please note that the paths to the executable programs must be specified as absolute paths.

Why is this necessary?

Some applications do not function properly after a reboot. This is often caused by invalid cache content. Which caches need to be cleared depends, of course, on the specific application.

Reboots are necessary, for example, as part of the punkt.de infrastructure patch days to make updated system packages available.