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

shell后台进程的更多相关文章

  1. linux shell 总结 (整理)

    ls /usr/bin/ info #路径操作 dirname basename #“”和‘’与 ` ` 在shell变量中的区别 “ ” 允许通过$符引用其他变量 ‘’禁止引用其他变量符,视为普通字 ...

  2. linux 基本命令___0001

    参考公众号:生信媛 参考链接:每天一个linux命令(61):wget命令 参考链接:<sort帮你排序>-linux命令五分钟系列之二十六 参考链接:每天一个linux命令(34):du ...

  3. 说一下linux中shell的后台进程与前台进程

    环境: 操作系统:archlinux; 终端模拟器:rxvt-unicode(urxvt); shell:bash; 这里所说的后台进程是指在命令行后面加一个 ampersand(&),前台进 ...

  4. shell直接退出后 后台进程关闭的原因和对处

    在linux上进行测试时发现启动后台进程后,如果使用exit退出登录shell,shell退出后后台进程还是能够正常运行,但如果直接关闭登陆的窗口(如直接关掉xshell),那后台进程就会一起终了.都 ...

  5. shell 获得后台进程返回值

    获得后台进程返回值我们用“&”把进程放入后台以后,如果需要了解进程的执行情况,可以使用wait函数.默认情况下wait会等待任意子进程结束但是不会返回子进程的返回值.而以子进程的pid作为参数 ...

  6. 用shell脚本守护后台进程

    假如现在在 crond 中添加了一个每分钟执行的定时任务如下: */ * * * * root cd /data/sbin; sh test.sh >/dev/>& 为了防止上一个 ...

  7. shell中后台进程管理: ps -aux 详解

    常用 查找进程id方法:      ps -aux | grep "jupyter"                杀进程:   kill -9 具体的PID 1.ps命令 要对进 ...

  8. Shell脚本监控Linux某个后台进程,当进程死掉后重新启动服务,以httpd为例

    Shell脚本如下: vim monitor.sh #!/bin/bash while true # 无限循环 flag=`ps -aux |grep "httpd" |grep ...

  9. crontab配置shell实现后台进程不间断运行

    检测get_report_no.php进程是否一直在运行 #!/bin/bash PROC=`ps -ef |grep get_report_no.php|grep -v grep|wc -l` if ...

随机推荐

  1. 多线程13-CountdownEvent

        );         ));             ));             t1.Start();             t2.Start();             _coun ...

  2. [DS+Algo] 009 树的介绍

    目录 1. 树的概念 2. 树的术语 3. 树的种类 4. 常见应用场景 5. 二叉树 1. 树的概念 每个结点(节点)有 0 个或多个子结点 没有父结点的结点称为根结点 每一个非根结点有且只有一个父 ...

  3. vue组件命名和传值

    一.vue组件命名: 组件有好几种命名方式, 可以使用 component-vue (短横线分隔命名).componentVue  (驼峰式命名) 或ComponentVue  (单词首字母) 因为h ...

  4. Linux cd命令(4)

    可以说在Linux上的一切操作都是从 cd 命令开始的.cd 是change directory的简写,其作用就是更改当前工作目录. 使用cd 对于这个命令的使用,不用多说了.需要注意的两点就是: c ...

  5. adb 配置连接

    一. adb环境安装 1.1. windown 驱动安装 1. 下载驱动(ADB Kits):http://adbshell.com/downloads 2. adb 测试 <1>. 解压 ...

  6. laravel5.5结合bootstrap上传插件fileinput 上传图片

    引入相关js <script src="{{ asset('bootstrap-fileinput/js/fileinput.js') }}"></script& ...

  7. 17: VUE数据绑定 与 Object.defineProperty

    VUE数据绑定原理:https://segmentfault.com/a/1190000006599500?utm_source=tag-newest Object.defineProperty(): ...

  8. Scrapy 教程(一)-安装与入门

    安装 具体请自行百度 依赖库 网上说pip安装会内分泌失调,我试了下还行吧,不过也遇到几个问题 解决方法 pip install -I cryptography 解决方法 pip install -U ...

  9. Macrotask Queue和Microtask Quque

    from:http://www.jianshu.com/p/3ed992529cfc setImmediate(function(){ console.log(1); },0); setTimeout ...

  10. windows无法安装.net framework 3.5解决方法

    windows server 12r2 或 win10 安装.netframework 3.5方法: 一. 直接在“启用或关闭windows功能”中可以启用,需联网.但是经常会出错,可能安装过程中需要 ...