File tree Expand file tree Collapse file tree 1 file changed +37
-14
lines changed Expand file tree Collapse file tree 1 file changed +37
-14
lines changed Original file line number Diff line number Diff line change 99
1010无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到` $HOME/nohup.out ` 文件中。如果没有文件能创建或打开以用于追加,那么 command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
1111
12- ###   语法    
12+ ### 语法  
1313
14+ ``` shell 
1415nohup(选项)(参数)
16+ ``` 
1517
16- ###   选项    
18+ ### 选项  
1719
1820``` shell 
1921--help:在线帮助;
2022--version:显示版本信息。
2123``` 
2224
23- ###   参数    
25+ ### 参数  
2426
2527程序及选项:要运行的程序及选项。
2628
27- ###  实例   
28- 
29+ ### 实例  
2930
3031使用nohup命令提交作业,如果使用nohup命令提交作业,那么在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件:
3132
@@ -47,16 +48,38 @@ nohup wget site.com/file.zip
4748nohup ping -c 10 baidu.com
4849``` 
4950
50- ### 最简单的后台运行  
51+ 最简单的后台运行
52+ 
53+ ``` shell 
5154nohup command  & 
52- ### 输出默认重定向到当前目录下 nohup.out 文件  
53- nohup python main.py &  
54- ### 自定义输出文件(标准输出和错误输出合并到 main.log)  
55- nohup python main.py >> main.log 2>&1 & 
56- ### 与上一个例子相同作用的简写方法  
55+ ``` 
56+ 
57+ 输出默认重定向到当前目录下 nohup.out 文件
58+ 
59+ ``` shell 
60+ nohup python main.py & 
61+ ``` 
62+ 
63+ 自定义输出文件(标准输出和错误输出合并到 main.log)
64+ 
65+ ``` shell 
66+ nohup python main.py >>  main.log 2>&1  & 
67+ ``` 
68+ 
69+ 与上一个例子相同作用的简写方法
70+ 
71+ ``` shell 
5772nohup python main.py & >  main.log & 
58- ### 不记录输出信息  
73+ ``` 
74+ 
75+ 不记录输出信息
76+ 
77+ ``` shell 
5978nohup python main.py & >  /dev/null & 
60- ### 不记录输出信息并将程序的进程号写入 pidfile.txt 文件中,方便后续杀死进程  
61- nohup python main.py &> /dev/null & echo $! > pidfile.txt
79+ ``` 
6280
81+ 不记录输出信息并将程序的进程号写入 pidfile.txt 文件中,方便后续杀死进程
82+ 
83+ ``` shell 
84+ nohup python main.py & >  /dev/null &  echo  $!  >  pidfile.txt
85+ ``` 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments