zoukankan      html  css  js  c++  java
  • shell后台进程

    建立duplicate_removal.sh文件,内容如下:
    #!/bin/bash
    mysql -vvv -u root -p123456 test -e "truncate t_target" &>/dev/null 
    date '+%H:%M:%S'
    for y in {1..4}
    do
      sql="call sp_unique($y)"
      mysql -vvv -u root -p123456 test -e "$sql" &>par_sql1_$y.log &
    done
    wait
    date '+%H:%M:%S'
    执行脚本文件
    ./duplicate_removal.sh
            执行输出如下:

    [mysql@hdp2~]$./duplicate_removal.sh
    14:27:30
    14:27:35
            这种方法用时5秒,并行执行的4个过程调用分别用时为4.87秒、4.88秒、4.91秒、4.73秒:

    [mysql@hdp2~]$cat par_sql1_1.log | sed '/^$/d'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    --------------
    call sp_unique(1)
    --------------
    Query OK, 124999 rows affected (4.87 sec)
    Bye
    [mysql@hdp2~]$cat par_sql1_2.log | sed '/^$/d'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    --------------
    call sp_unique(2)
    --------------
    Query OK, 125000 rows affected (4.88 sec)
    Bye
    [mysql@hdp2~]$cat par_sql1_3.log | sed '/^$/d'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    --------------
    call sp_unique(3)
    --------------
    Query OK, 125000 rows affected (4.91 sec)
    Bye
    [mysql@hdp2~]$cat par_sql1_4.log | sed '/^$/d'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    --------------
    call sp_unique(4)
    --------------
    Query OK, 125001 rows affected (4.73 sec)
    Bye
    [mysql@hdp2~]$
    ---------------------

  • 相关阅读:
    Uva11235
    Uva11300/BZOJ1045/BZOJ1465/BZOJ3292
    树形背包模板
    Miller-Rabin素性测试
    BZOJ1500 : [NOI2005]维修数列-fhq_Treap
    COGS2421 [HZOI 2016]简单的Treap
    用 fhq_Treap 实现可持久化平衡树
    hdu 1010(DFS) 骨头的诱惑
    hdu 1026(BFS+输出路径) 我要和怪兽决斗
    hdu 1072(BFS) 有炸弹
  • 原文地址:https://www.cnblogs.com/ly570/p/11311245.html
Copyright © 2011-2022 走看看