markdown 创建新的Linux服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 创建新的Linux服务相关的知识,希望对你有一定的参考价值。

#### 1. Create a script and place in /etc/init.d (e.g /etc/init.d/myscript). The script should have the following format:

```bash
#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    # code to start app comes here 
    # example: daemon program_name &
}

stop() {
    # code to stop app comes here 
    # example: killproc program_name
}

case "$1" in 
    start)
       start
       ;;
    stop)
       stop
       ;;
    restart)
       stop
       start
       ;;
    status)
       # code to check status of app comes here 
       # example: status program_name
       ;;
    *)
       echo "Usage: $0 {start|stop|status|restart}"
esac

exit 0
```

The format is pretty standard and you can view existing scripts in /etc/init.d. You can then use the script like so /etc/init.d/myscript start or chkconfig myscript start. The ckconfig man page explains the header of the script:

```
 > This says that the script should be started in levels 2,  3,  4, and
 > 5, that its start priority should be 20, and that its stop priority
 > should be 80.
 ```
 
 The example start, stop and status code uses helper functions defined in /etc/init.d/functions


#### 2. Enable the script

```bash
$ chkconfig --add myscript 
$ chkconfig --level 2345 myscript on 
```

#### 3. Check the script is indeed enabled - you should see "on" for the levels you selected.

```bash
$ chkconfig --list | grep myscript
```

以上是关于markdown 创建新的Linux服务的主要内容,如果未能解决你的问题,请参考以下文章

新的vim自带markdown插件,请问markdown怎么折叠文本,只显示标

markdown 创建新的SSH密钥

markdown 创建新的SSH密钥

markdown 创建一个新的Git(Hub)项目

markdown git创建一个新的存储库

Linux下SVN创建新的项目