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~]$
    ---------------------

  • 相关阅读:
    新博客即将启用
    关于博主 | 联系博主
    结束吧,为这不圆满的故事划上一个残缺的句号
    自用线段树模板
    NOIP 2017 day 1 游记
    NOIP 2017 Day 0. 游记
    NOIP 2017 day -1 杂记
    再一次想不出应该起什么标题
    做图与树做到吐的一天
    自用二分图匹配模板
  • 原文地址:https://www.cnblogs.com/ly570/p/11311245.html
Copyright © 2011-2022 走看看