Memory Loom » database http://192.168.0.198 Apologia, decisions, & consequences Sat, 17 May 2025 04:27:08 +0000 en-US hourly 1 http://wordpress.org/?v=3.4.2 Automated Database Restart http://192.168.0.198/?p=113 http://192.168.0.198/?p=113#comments Sun, 21 Jan 2024 22:41:11 +0000 Elijah Thomas http://192.168.0.198/?p=113 Here is a script that checks to ensure the database is running and restarts the service if it is not running.  This was used on a very low memory server to ensure a database remained operational, despite it sometimes crashing due to out of memory errors.

#!/bin/bash

timestamp="$(date)"
systemctl stop httpd && echo "${timestamp}" Stopping Apache... >> /home/centos/administration/apache.log
systemctl is-active mariadb && echo "${timestamp}" MariaDB is active so not starting >> /home/centos/administration/mariadb_active.log || echo "${timestamp}" MariaDB is not Active >> /home/centos/administration/mariadb_inactive.log
systemctl is-active mariadb && echo "${timestamp}" No need to restart MariaDB || systemctl start mariadb
systemctl start httpd && echo "${timestamp}" restarting apache...>> /home/centos/administration/apache.log
]]>
http://192.168.0.198/?feed=rss2&p=113 0