nohup sleep 2 >/dev/null 2>&1 &命令啥意思?
时间: 2023-11-04 08:56:25 浏览: 161
nohup sleep 2 >/dev/null 2>&1 & 命令的意思是在后台运行一个名为 sleep 的命令,持续执行 2 秒,并且将输出定向到 /dev/null,即丢弃所有的输出信息,同时将标准错误也重定向到标准输出。
这个命令的主要目的是让 sleep 命令在后台默默执行,不会在终端上产生任何输出。通过将输出定向到 /dev/null,可以有效地隐藏命令的输出信息。
相关问题
#!/bin/sh #HOME=/ BIN=PLCXPro stoprun() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1" | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then echo "$1 id is $PID, kill normal process!" kill -3 $PID else echo "$1 id $PID is down! it's over!" fi } stoprunstart() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1"|grep start | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then echo "$1 id is $PID, kill normal process!" kill -9 $PID else echo "$1 id $PID is down! it's over!" fi } runtest() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1" | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then ## echo $1 id is $PID, sys normal process! sleep 30 else echo $1 is down! reload the process! date echo nohup $BIN & nohup ./$BIN > /dev/null & fi }怎么开启或者重启这个PLCXPro
可以运行以下命令来重启 PLCXPro 进程:
```
./stopapp.sh PLCXPro
```
该命令会执行 stoprun 函数,查找并终止名为 PLCXPro 的进程。
然后再执行以下命令来启动 PLCXPro 进程:
```
./runapp.sh PLCXPro
```
该命令会执行 runtest 函数,查找名为 PLCXPro 的进程是否已经存在,若不存在则启动 PLCXPro 进程。
#!/bin/bash print_log=$(tail -n 1000 /home/cti/.ros/cloud_scheduling_node/cloud_scheduling_node.log | grep -a 状态预览 | tail -n 1 | awk '{print $0}') reboot=false for argument in "$@";do if [[ $argument == "reboot" ]];then reboot=true echo reboot needed fi done building=$(echo $print_log | awk -F '大楼全称: "' '{print $2}' | awk -F '"' '{print $1}') floor=$(echo $print_log | awk -F '当前位置: \\(' '{print $2}' | awk -F 'F' '{print $1}') x=$(echo $print_log | awk -F 'x:' '{print $2}' | awk -F "y" '{print $1}') y=$(echo $print_log | awk -F 'y:' '{print $2}' | awk -F "yaw" '{print $1}') yaw=$(echo $print_log | awk -F 'yaw:' '{print $2}' | awk -F "]" '{print $1}') if $reboot;then echo rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" >topic.bash else echo rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" >topic.bash fi date echo 正在停止服务! sudo service br stop sleep 3 for package in "$@";do if [[ "$package" == br*.deb ]];then sudo dpkg -i --force-overwrite "$package" echo $package 版本升级成功 sleep 3 fi done #source /opt/cti/kinetic/setup.bash #cd /opt/cti/kinetic/share/br_bringup/launch/ #nohup roslaunch br_bringup start_br.launch &>/dev/null& #echo "###################################################################################################################################" #sleep 5 #echo "###################################################################################################################################" #if $reboot;then # date # date # date # echo "###################################################################################################################################" # rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" # echo rostopic pub /mission_schedule/force_reboot mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" #else # date # date # date # echo "###################################################################################################################################" # rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" # echo rostopic pub /mission_schedule/relocate mission_schedule/coordinatesMsg "\"{buildingName: '$building', floorName: '$floor', x: $x, y: $y, yaw: $yaw}"\" #fi
这是一个Bash脚本,主要功能是根据指定的日志文件,提取出最后1000行中包含“状态预览”的行,并从中提取出大楼名称、楼层、位置坐标和偏航角等信息。根据脚本的参数,可以选择是否重启机器人,并在执行重启或者重新定位的操作之前,停止机器人相关的服务,并升级指定的软件包。
该脚本的注释已经很详细,但是可能需要根据实际情况进行一些修改才能正确运行。
阅读全文