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