- Create bash script file, eg.
nano /opt/scripts/reload-service.sh, add these commands in the file:
#!/bin/bash
NOW=$(date +"%d.%m.%Y_-_%H:%M:%S")
systemctl -q is-active mongod.service || \
echo "$NOW Mongod service down, restarting..." \
sudo service mongod restart