要启动散居国外者,需要运行以下命令:
cd /家庭/散居国外者
./script/sever
我的服务器(Ubuntu11.10)每天重新启动。我需要配置服务器(Ubuntu11.10),以便在服务器启动时允许侨民服务器启动。该怎么做呢?
我试过:
以运行散居状态的用户登录,打开crontab编辑器(crontab -e),滚动到末尾并输入:
@reboot cd /home/散居;./script/sever
然后保存,但它仍然没有启动后,我的服务器启动。
而且,如果crontab -e不能这样做,是否可以编写init脚本来做到这一点?如果init脚本能够做到这一点,那么如何编写脚本来完成呢?
发布于 2012-02-03 01:56:03
首先,您需要创建init脚本:
# This is the init script for starting up the
# Diaspora
#
# chkconfig: 345 91 10
# description: Starts and stops the Diaspora daemon.
#
PROC_NAME=Diaspora
DIASPORA_HOME=/home/diaspora
# Change the user to whichever user you need
RUN_AS_USER=diaspora
startup="cd $DIASPORA_HOME; ./script/server"
# Replace by stop/shutdown command
#shutdown="$DIASPORA_HOME/script/server"
start(){
echo -n $"Starting $PROC_NAME service: "
su -l $RUN_AS_USER -c "$startup"
RETVAL=$?
echo
}
stop(){
echo -n $"Stoping $PROC_NAME service: "
# Uncomment here to allow stop
# su -l $RUN_AS_USER -c "$shutdown"
RETVAL=$?
echo
}
restart(){
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0然后使该文件可执行:
sudo chmod +x /etc/init.d/diaspora然后,您需要告诉Ubuntu启动/停止,通常使用默认的运行级别(假设您将前面的脚本保存在/etc/init.d/diaspora中):
sudo update-rc.d diaspora defaults那就试试吧:
sudo service diaspora start或
sudo /etc/init.d/diaspora start如果散居国外的人开始,你就可以走了。否则脚本可能需要调整。
https://stackoverflow.com/questions/9122488
复制相似问题