check_ssh.sh
#!/bin/bash
#*/5 * * * * /home/check_ssh.sh
process_day=`date -d today +"%Y-%m-%d %H:%M"`
process=`ps -ef | grep -v 'grep' | grep "<sshd>" | awk '{print $2}' |wc -l`
my_log="/home/check_sshd.log"
if [ $process -gt 0 ]
then
echo ${process_day} "sshd is running" >> $my_log
else
echo ${process_day} >> $my_log
/etc/init.d/sshd start >> $my_log
fi