Liunx在開機後,自動啓動openldap、radius、memcached等程序的shell腳本

如下是腳本命令:bash

 

#!/bin/bashmemcached

#說明:此文件需放在/etc/rc.d/init.d/目錄下,而後編輯文件/etc/rc.d/rc.local,在裏面添加bash /etc/init.d/Autorun.sh
#腳本做用:是在開機後,啓動openldap、radius、memcached程序
#date +%c > /opt/tmp/Autorun-log.txtit

echo 開機啓動腳本開始執行 > /opt/tmp/Autorun-log.txtdate

fun1(){
echo "進入openldap目錄" >> /opt/tmp/Autorun-log.txt
cd /usr/local/openldap/libexec
echo "執行啓動命令" >> /opt/tmp/Autorun-log.txt
./slapd
if [ $?==0 ]
then
echo "命令執行成功" >> /opt/tmp/Autorun-log.txt
else
echo "命令執行失敗" >> /opt/tmp/Autorun-log.txt
fi
}
fun2(){
echo "啓動radius" >> /opt/tmp/Autorun-log.txt
/usr/local/radius/sbin/radiusd -d /usr/local/radius/etc/raddb/ &
echo "radius啓動成功" >> /opt/tmp/Autorun-log.txt
echo "啓動memcached" >> /opt/tmp/Autorun-log.txt
/usr/local/memcached/bin/memcached -d -m 100 -u root -p 11211 -c 1024 -p /tmp/memcached.pid
echo "memcached啓動成功" >> /opt/tmp/Autorun-log.txt
}
fun1
fun2
echo "腳本執行完成" >> /opt/tmp/Autorun-log.txt
date +%c >> /opt/tmp/Autorun-log.txt程序

相關文章
相關標籤/搜索