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

  • 相关阅读:
    《学习之道》第十章方法空间能力是可以后天形成的
    《学习之道》第十章总结
    《学习之道》第十章视觉和空间记忆的原因
    数据结构之链表:双指针问题
    单例模式
    Java的锁
    Python锁
    排序算法小结
    命中索引
    反射
  • 原文地址:https://www.cnblogs.com/ly570/p/11311245.html
Copyright © 2011-2022 走看看