注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

zjc的博客

技术积累

 
 
 

日志

 
 

suse系统自动启动应用程序  

2009-01-06 11:42:19|  分类: 操作系统 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 

 /etc/init.d/目录下建立如下脚本,别忘了建好后赋权限哦

#! /bin/sh

# Copyright (c) 2009--2010 DEEFEI .

#

# Author: ZJC <zjcdillion@163.com>, 2009-2010

#

# /etc/init.d/df_soft

#

#   and symbolic its link

#

# /usr/sbin/rcdf_soft                                      #//此处为一个链接,使用ln命令产生

#

# System startup script for the df_soft

#

### BEGIN INIT INFO

# Provides:       df_soft                                 #//此处名称需要与脚本名一致

# Required-Start: $network $splash_late                    #//决定你的脚本启动顺序,此处为在

                                                                                      #//network之后启动

# Default-Start:  3 5                                                               #//在哪一级启动,此处为3、5级启动

# Default-Stop: 

# Description:    df_soft job service

### END INIT INFO

 

# Source SuSE config

. /etc/rc.status

 

DFSOFT_BIN=/usr/local/bin/dfads_start.sh                                #//此处为启动程序(脚本)地址

test -x $DFSOFT_BIN || { echo "Nor /usr/local/bin/dfads_start.sh  exists"; rc_failed 5; rc_status -v; rc_exit; }

                                                                                     #检测是否存在启动程序(脚本)

# Shell functions sourced from /etc/rc.status:

#      rc_check         check and set local and overall rc status

#      rc_status        check and set local and overall rc status

#      rc_status -v     ditto but be verbose in local rc status

#      rc_status -v -r  ditto and clear the local rc status

#      rc_failed        set local and overall rc status to failed

#      rc_failed <num>  set local and overall rc status to <num><num>

#      rc_reset         clear local rc status (overall remains)

#      rc_exit          exit appropriate to overall rc status

. /etc/rc.status

echo "RC status@@@@"                                                   #//此处为调试时添加,可去掉

# First reset status of this service

rc_reset

echo "RC reset@@@@"                                                    #//此处为调试时添加,可去掉

# Return values acc. to LSB for all commands but status:

# 0 - success

# 1 - generic or unspecified error

# 2 - invalid or excess argument(s)

# 3 - unimplemented feature (e.g. "reload")

# 4 - insufficient privilege

# 5 - program is not installed

# 6 - program is not configured

# 7 - program is not running

#

# Note that starting an already running service, stopping

# or restarting a not-running service as well as the restart

# with force-reload (in case signalling is not supported) are

# considered a success.

 

case "$1" in

    start)

echo -n "Starting DFSOFT "

## Start daemon with startproc(8). If this fails

## the echo return value is set appropriate.

 

# NOTE: startproc return 0, even if service is

# already running to match LSB spec.

$DFSOFT_BIN                                                          #//启动脚本,命令行可执行 rcdf_soft start

                                                                              #//如果为应用程序,请参考cron脚本启动

# Remember status and be verbose

rc_status -v

;;

    stop)

echo -n "Shutting down DFSOFT"

## Stop daemon with killproc(8) and if this fails

## set echo the echo return value.

 

Killall dfads                                                             #//杀死应用程序

 

# Remember status and be verbose

rc_status -v

;;

    try-restart)

## Stop the service and if this succeeds (i.e. the

## service was running before), start it again.

## Note: try-restart is not (yet) part of LSB (as of 0.7.5)

$0 status >/dev/null &&  $0 restart

 

# Remember status and be quiet

rc_status

;;

    restart)

## Stop the service and regardless of whether it was

## running or not, start it again.

$0 stop

$0 start

 

# Remember status and be quiet

rc_status

;;

    force-reload)

## Signal the daemon to reload its config. Most daemons

## do this on signal 1 (SIGHUP).

## If it does not support it, restart.

 

echo -n "Reload service Cron"

## if it supports it:

        ## cron monitors /etc/crontab  anyway

#checkproc $DFSOFT_BIN

#rc_status -v

 

## Otherwise:

#$0 stop  &&  $0 start

#rc_status

;;

    reload)

## Like force-reload, but if daemon does not support

## signalling, do nothing (!)

 

## Otherwise if it does not support reload:

rc_status -v

;;

    status)

echo -n "Checking for DFSOFT: "

## Check status with checkproc(8), if process is running

## checkproc will return with exit status 0.

 

# Status has a slightly different for the status command:

# 0 - service running

# 1 - service dead, but /var/run/  pid  file exists

# 2 - service dead, but /var/lock/ lock file exists

# 3 - service not running

# NOTE: checkproc returns LSB compliant status values.

#checkproc $DFSOFT_BIN

rc_status -v

;;

    probe)

## Optional: Probe for the necessity of a reload,

## give out the argument which is required for a reload.

;;

    *)

echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"

exit 1

;;

esac

rc_exit

 

请按顺序执行下列命令

1。Chkconfig –level 35 df_soft            //配置入系统启动项

2。Chkconfig –level 35 df_soft on       //配置入系统启动项

3。Ln –s /etc/init.d/df_soft /usr/sbin/rcdf_soft             //添加连接

 4。Rcdf_soft start                                                       //测试启动

  评论这张
 
阅读(810)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018