After spending too long trying to debug my Endeavour OS which had ramdom
system hangs I decide to write a script to get me out of the problem
when it occurred.
I have written this for beginners and hopefully it will be easy to
follow.
This script will give you a graceful shutdown during a system hang.
You need to create conf file in /etc/sysctl.d
Just press Ctrl+Alt+T to bring up a Terminal
Run the command below to create the conf file
echo kernel.sysrq=1 | sudo tee -a /etc/sysctl.d/99-sysctl.conf
Also in the Terminal run the following command below to reload the conf
files without rebooting the computer** su -c "sysctl –system" **You maybe
ask for your password.
We now need to create the mail script file
In the Terminal type** sudo nano /usr/local/bin/sysh.sh
Add the following to the** sysh.sh **and safe it.
#!/bin/sh
# cat /usr/local/bin/sysh.sh
for c in r s u o; do
echo $c > /proc/sysrq-trigger
sleep 2
done
We need to make the sysh.sh script executable
In the Terminal type** sudo chmod +x /usr/local/bin/sysh.sh
We need to add the following to the /.bashrc file
If you are the zsh you will need add the following to the /.zshrc file
Open the .bashrc In the Terminal type** sudo nano ~/.bashrc scroll
to the bottom of the file add the following and save the file.
# Sysrq key combo for system hang
alias sysh='sudo /usr/local/bin/sysh.sh'
Finely the Terminal type source** ~/.bashrc or ~/.zshrc
You can now test the script by Ctrl+Alt+F4 which Opens TTY
You will need to login once login type sysh and the system will graceful
shutdown after about 2 seconds.
This all so works on any Arch base system.
TomX