簡介:
nohup 命令運行由 Command參數和任何相關的 Arg參數指定的命令,忽略所有掛斷(SIGHUP)信號。在注銷后使用 nohup 命令運行后台中的程序。要運行后台中的 nohup 命令,添加 & ( 表示“and”的符號)到命令的尾部。
用途:不掛斷地運行命令。
語法:nohup Command [ Arg ... ] [ & ]
描述:nohup 命令運行由 Command 參數和任何相關的 Arg 參數指定的命令,忽略所有掛斷(SIGHUP)信號。在注銷后使用 nohup 命令運行后台中的程序。要運行后台中的 nohup 命令,添加 & ( 表示“and”的符號)到命令的尾部。
該命令的一般形式為:nohup command &
使用nohup命令提交作業
如果使用nohup命令提交作業,那么在缺省情況下該作業的所有輸出都被重定向到一個名為nohup.out的文件中,除非另外指定了輸出文件:
nohup command > myout.file 2>&1 &
在上面的例子中,0 – stdin (standard input),1 – stdout (standard output),2 – stderr (standard error) ;
2>&1是將標准錯誤(2)重定向到標准輸出(&1),標准輸出(&1)再被重定向輸入到myout.file文件中。
使用 jobs 查看任務。
使用 fg %n 關閉。
示例:
nohup /app/my/tommyduan_service/submit_generate_all.sh 20171231 570 ALL 20171231 20180101 >my_log_20171231_570.log 2>&1 &
監控日志的方法:
tailf my_log_20171231_570.log tail -f my_log_20171231_570.log
submit_generate_all.sh文件:
1 #!/usr/bin/env bash 2 source /app/catt/login.sh 3 4 p_day=$1 5 p_city=$2 6 p_loctype=$3 7 p_mr_location_imsi_all_start=$4 8 p_mr_location_imsi_all_end=$5 9 10 time beeline<<EOF 11 12 use rc_hive_db; 13 14 set mapred.job.name=generate_gridcell_grid_floor_building_${p_day}_${p_city}_${p_loctype}; 15 16 set hive.exec.reducers.bytes.per.reducer=500000000; 17 set hive.mapred.supports.subdirectories=true; 18 set mapreduce.input.fileinputformat.input.dir.recursive=true; 19 set mapred.max.split.size=256000000; 20 set mapred.min.split.size.per.node=128000000; 21 set mapred.min.split.size.per.rack=128000000; 22 set hive.hadoop.supports.splittable.combineinputformat=true; 23 set hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat; 24 set hive.merge.mapfiles=true; 25 set hive.merge.mapredfiles=true; 26 set hive.merge.size.per.task=256000000; 27 set hive.merge.smallfiles.avgsize=256000000; 28 set hive.groupby.skewindata=true; 29 set hive.exec.dynamic.partition.mode=nonstrict; 30 set hive.exec.parallel=true; 31 set hive.exec.parallel.thread.number=32; 32 SET hive.exec.compress.output=true; 33 SET mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec; 34 SET mapred.output.compression.type=BLOCK; 35 set hive.exec.compress.intermediate=true; 36 set hive.intermediate.compression.codec=org.apache.hadoop.io.compress.SnappyCodec; 37 set hive.intermediate.compression.type=BLOCK; 38 39 40 drop table tommyduan_fingerlib_${p_day}_${p_city}_all;
備注:
1)其中/app/my/tommyduan_service/submit_generate_all.sh是的sh文件;
2)其中 20171231 570 ALL 20171231 20180101,是sh文件接收的參數信息;
3)其中my_log_20171231_570.log 會記錄輸入、輸出、錯誤流信息。