【问题标题】:I am trying to run jobs -l command in my for loop but it is just displaying the the parameter not the actual values我正在尝试在我的 for 循环中运行 jobs -l 命令,但它只是显示参数而不是实际值
【发布时间】:2020-01-11 16:52:52
【问题描述】:

我正在尝试通过循环中的 for 循环运行脚本,我在每个进程启动后给出 jobs -l 命令,然后我捕获到日志中,它只显示带有参数的执行命令,而不是实际参数值,有没有办法将包含实际参数的内容捕获到日志中。

for table_name in `cat exec.lst`
    ./abc.sh ${table_name} 1>&2 2>>table_name.log &

jobs -l | grep abc.sh > ${LOG_DIR}/tables_status.list 

jobs -l 命令的输出:

[1]10283 Done ./abc.sh ${table_name} 1>&2 2>>${LOG_DIR}/${table_name}.log
[2]10323 Done ./abc.sh ${table_name} 1>&2 2>>${LOG_DIR}/${table_name}.log
[3]10362 Done ./abc.sh ${table_name} 1>&2 2>>${LOG_DIR}/${table_name}.log            
[4]10403 Done ./abc.sh ${table_name} 1>&2 2>>${LOG_DIR}/${table_name}.log              
[5]10443 Done ./abc.sh ${table_name} 1>&2 2>>${LOG_DIR}/${table_name}.log              

有没有其他方法可以获取实际表名的信息。

预期输出:

[1]10283 Done ./abc.sh table1 1>&2 2>>${LOG_DIR}/table1.log
[2]10323 Done ./abc.sh table2 1>&2 2>>${LOG_DIR}/table2.log
[3]10362 Done ./abc.sh table3 1>&2 2>>${LOG_DIR}/table3.log               
[4]10403 Done ./abc.sh table4 1>&2 2>>${LOG_DIR}/table4.log                  
[5]10443 Done ./abc.sh table5 1>&2 2>>${LOG_DIR}/table5.log

【问题讨论】:

    标签: shell unix scripting


    【解决方案1】:

    试试这个,我不确定

    ./abc.sh ${table_name} 2>&1 >> {table_name}.log &
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 2015-01-13
      相关资源
      最近更新 更多