cPanel has service called chkservd which automatically start service on stop. The configuration file is stored in the location, > /etc/chkserv.d/chkservd.conf and you can find the service to check on stop
To restart chkservd, execute the command /scripts/restartsrv_chkservd , which will restart tailwatchd service.
The tailwatcd service status can be found from the command,
/usr/local/cpanel/libexec/tailwatchd --status
if you get error like,
====
ATTENTION ATTENTION ATTENTION ATTENTION
Cpanel::TailWatch::Eximstats appears to have unprocessed SQL in /var/cpanel/sql/eximstats.sql.
=-=-
Please execute the below commands as a solution,
-==-
mv /var/cpanel/sql/eximstats.sql /var/cpanel/sql/eximstats.sql.tmp_working_copy
/scripts/restartsrv_tailwatchd
mysql eximstats < /var/cpanel/sql/eximstats.sql.tmp_working_copy
=-=-
Done..
Simple script to restart apache in servers without cPanel,
Create a script file, apacheup.sh and put the below command
-==-
#/bin/bash
RESTART="/sbin/service httpd restart"
PGREP="/usr/bin/pgrep"
HTTPD="httpd"
$PGREP ${HTTPD}
if [ $? -ne 0 ]
then
$RESTART
fi
=-=-
Put a cron preferrably each hour.
crontab -e
* */1 * * * /location/apacheup.sh
You can also use the below commands to find the apache uptime,
httpd fullstatus | grep -i uptime (For cPanel Servers)
ps -eo "%U %c %t"|grep httpd |grep -v grep|grep root (Any servers)
To restart chkservd, execute the command /scripts/restartsrv_chkservd , which will restart tailwatchd service.
The tailwatcd service status can be found from the command,
/usr/local/cpanel/libexec/tailwatchd --status
if you get error like,
====
ATTENTION ATTENTION ATTENTION ATTENTION
Cpanel::TailWatch::Eximstats appears to have unprocessed SQL in /var/cpanel/sql/eximstats.sql.
=-=-
Please execute the below commands as a solution,
-==-
mv /var/cpanel/sql/eximstats.sql /var/cpanel/sql/eximstats.sql.tmp_working_copy
/scripts/restartsrv_tailwatchd
mysql eximstats < /var/cpanel/sql/eximstats.sql.tmp_working_copy
=-=-
Done..
Simple script to restart apache in servers without cPanel,
Create a script file, apacheup.sh and put the below command
-==-
#/bin/bash
RESTART="/sbin/service httpd restart"
PGREP="/usr/bin/pgrep"
HTTPD="httpd"
$PGREP ${HTTPD}
if [ $? -ne 0 ]
then
$RESTART
fi
=-=-
Put a cron preferrably each hour.
crontab -e
* */1 * * * /location/apacheup.sh
You can also use the below commands to find the apache uptime,
httpd fullstatus | grep -i uptime (For cPanel Servers)
ps -eo "%U %c %t"|grep httpd |grep -v grep|grep root (Any servers)