Just like restarting a server when the memory is low, I’ve had a recent problem with kernel panics on my Raspberry Pi, and I’ve found a terrible solution to fix it: Just reboot.
Because I’m lazy, I asked ChatGPT to write me up a startup script to do this for me, and here’s what I have now:
To set the panic
timeout value on Ubuntu Server 20.04 and later versions, you can create a systemd service unit file.
Here are the steps to create a systemd service unit file:
- Open a terminal window on your Ubuntu Server.
- Create a new service unit file with the following command:
sudo nano /etc/systemd/system/panic-timeout.service
This will open a new file namedpanic-timeout.service
in the nano text editor with superuser privileges. - Add the following lines to the file:
[Unit]
Description=Panic Timeout
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo 60 > /proc/sys/kernel/panic"
[Install]
WantedBy=multi-user.target
Code language: JavaScript (javascript)
This service unit file sets the panic timeout to 60 seconds.
- Save the file by pressing
Ctrl+O
, then exit nano by pressingCtrl+X
. - Reload the systemd daemon to recognize the new service unit file with the following command:
sudo systemctl daemon-reload
- Enable the service unit file to run at boot time with the following command:
sudo systemctl enable panic-timeout.service
- Reboot the server to test the service unit file. After the server reboots, the
panic-timeout.service
will automatically run theecho
command and set the panic timeout to 60 seconds.
That’s it! With these steps, you can set the panic
timeout value on the latest versions of Ubuntu Server.
Well there you have it! Don’t forget to follow along for more terrible ideas!
Leave a Reply