PATH=/sbin:/bin:/usr/bin:/usr/sbin DAEMON=/usr/sbin/chronyd PIDFILE=/var/run/chronyd.pid 啥意思
时间: 2024-03-02 14:47:03 浏览: 37
这是一段关于Linux系统中的路径设置和守护进程配置的文本。
1. `PATH=/sbin:/bin:/usr/bin:/usr/sbin`:这是一个环境变量,用于指定系统在查找可执行文件时搜索的目录列表。在这个例子中,系统会按照这个顺序在这些目录下查找可执行文件。
2. `DAEMON=/usr/sbin/chronyd`:这是一个变量,用于指定守护进程(daemon)的路径。在这个例子中,守护进程是`/usr/sbin/chronyd`。
3. `PIDFILE=/var/run/chronyd.pid`:这是一个变量,用于指定守护进程的进程ID文件(PID file)的路径。在这个例子中,进程ID文件是`/var/run/chronyd.pid`。
相关问题
给我一份nginx通过/etc/init.d的启动脚本
以下是一个简单的nginx通过/etc/init.d的启动脚本:
```
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx web server
# Description: nginx is a high-performance web server and reverse proxy.
### END INIT INFO
# Author: Your Name <your.email@example.com>
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nginx
NAME=nginx
DESC=nginx
# Check if binary exists
test -x $DAEMON || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present.
. /lib/lsb/init-functions
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
# Function that starts the daemon/service
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- \
$DAEMON_OPTS \
|| return 2
}
# Function that stops the daemon/service
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/$NAME.pid
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f /var/run/$NAME.pid
return "$RETVAL"
}
# Function that sends a SIGHUP to the daemon/service
do_reload() {
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON --name $NAME
return 0
}
# Function that returns the status of the daemon/service
do_status() {
status_of_proc -p /var/run/$NAME.pid "$DAEMON" "$NAME" && exit 0 || exit $?
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
do_status
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2
exit 3
;;
esac
exit 0
```
将此脚本保存到/etc/init.d/nginx,并确保其可执行。之后你就可以使用以下命令启动、停止、重启和检查状态:
```
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
sudo service nginx status
```
● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2023-06-01 15:30:44 CST; 21s ago Docs: man:nginx(8) Process: 16533 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 16794 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE) Main PID: 16377 (code=exited, status=0/SUCCESS) Jun 01 15:30:44 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server... Jun 01 15:30:44 ubuntu nginx[16794]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:87 Jun 01 15:30:44 ubuntu nginx[16794]: nginx: configuration file /etc/nginx/nginx.conf test failed Jun 01 15:30:44 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1 Jun 01 15:30:44 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'. Jun 01 15:30:44 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
根据错误信息,你的Nginx配置文件中存在语法错误,导致Nginx服务启动失败。具体来说,错误信息显示在/etc/nginx/nginx.conf文件的第87行,其中包含了一个不允许在此处使用的"server"指令。
你需要打开/etc/nginx/nginx.conf文件,并检查第87行的语法是否正确。可能需要注意的是,Nginx配置文件中的指令是有一定的嵌套关系的,因此你需要确保"server"指令的位置是正确的,如果在错误的位置使用"server"指令,就会导致语法错误。
在修改之后,你需要保存文件并检查语法是否正确。可以使用以下命令来检查Nginx配置文件的语法:
```
sudo nginx -t
```
如果语法正确,则命令将不会输出任何信息。如果存在语法错误,则命令将会给出相应的错误信息,你需要根据错误信息进行修正。完成修正之后,你需要重启Nginx服务,使新的配置文件生效。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)