Skip to content

Adrian Ng's Notes

Documenting my journey experiencing new technologies and life

Tag: linux

Bash script to check if a process is running and if failed, restart it

Thanks to Karson for this one.

Create a file:

sudo nano ./run.sh

#!/bin/sh
if ps -ef | grep -v grep | grep boinc ; then
exit 1
else
sudo systemctl restart boinc-client &
exit 0
fi

Change permissions

sudo chmod +x ./run.sh

Make it run automatically

crontab -e

Every second

* * * * * /home/user/run.sh
Author AdrianPosted on September 12, 2023April 13, 2024Categories bash, boinc, LinuxTags bash, check if process is running, crontab, linuxLeave a comment on Bash script to check if a process is running and if failed, restart it

Recent Posts

  • Windows 11 Upgrade
  • Resync Windows Password with Microsoft Account
  • Upgrading Ubuntu
  • How To Check If A Youtube Video Is Monetized
  • SSD health

Recent Comments

  • A WordPress Commenter on Hello world!

Archives

  • January 2026
  • August 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • September 2023
  • August 2023
  • April 2023
  • December 2022
  • November 2022
  • September 2022
  • May 2022
  • April 2022
  • June 2021
  • May 2021
  • April 2021
  • October 2016

Categories

  • bash
  • boinc
  • Certifications
  • Cloud
  • Commercial Technology
  • DNS
  • Home Lab
  • Linux
  • Networking
  • Technology
  • Uncategorized
  • Website
  • Windows
  • Wordpress

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Adrian Ng's Notes Proudly powered by WordPress