___
# Tags
#bash
#homelab
#script
#suricata
#ubuntu
# Helpful docs
- https://stackoverflow.com/questions/34931846/cronjob-to-check-and-restart-service-if-dead
## Setup a script by using your favorite text editor on your linux host
```txt
sudo nano service-check.sh
```
## Make it executable
```txt
chmod +x service-check.sh
```
## Paste your service name inside the variable declared at the top
```txt
#!/bin/bash
SERVICENAME="suricata.service"
systemctl is-active --quiet $SERVICENAME
STATUS=$? # return value is 0 if running
if [[ "$STATUS" -ne "0" ]]; then
echo "Service '$SERVICENAME' is not curently running... Starting now..."
service $SERVICENAME start
fi
```