2021-7

一. 网址参考

  1. linux >和>>的区别,<号使用

  2. start-stop-daemon 用法

  3. 我可以在Bash中使Tab自动补全不区分大小写吗?

  4. Linux cp命令如何拷贝整个目录下所有文件

  5. linux复制指定目录下的全部文件到另一个目录中,linux cp 文件夹

  6. Shell重定向 &>file、2>&1、1>&2 、/dev/null的区别

  7. Linux 修改时区和时间

  8. OpenWrt开发必备软件模块——系统总线ubus

二. 实践

  1. nginx的启动脚本中的start-stop-daemon用法, /etc/init.d/nginx:

# Try to extract nginx pidfile
PID=$(cat /etc/nginx/nginx.conf | grep -Ev '^s*#' | awk 'BEGIN { RS="[;{}]" } { if ($1 == "pid") print $2 }' | head -n1)
if [ -z "$PID" ]; then
    PID=/run/nginx.pid
fi

if [ -n "$ULIMIT" ]; then
    # Set ulimit if it is set in /etc/default/nginx
    ulimit $ULIMIT
fi

start_nginx() {
    # Start the daemon/service
    #
    # Returns:
    #   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 $PID --exec $DAEMON --test > /dev/null 
        || return 1
    start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- 
        $DAEMON_OPTS 2>/dev/null 
        || return 2
}

test_config() {
    # Test the nginx configuration
    $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1
}

stop_nginx() {
    # Stops the daemon/service
    #
    # 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=$STOP_SCHEDULE --pidfile $PID --name $NAME
    RETVAL="$?"
    sleep 1
    return "$RETVAL"
}

   2. bash补全不区分大小写

  ~/.inputrc文件

  $include /etc/inputrc

  # Case-insensitive tab completion
  set completion-ignore-case on

 

原文地址:https://www.cnblogs.com/shanyu20/p/14972051.html