建立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. net 架构师-数据库-sql server-002-工具

    本章讲述的工具包括: SQL Server 联机丛书 SQL Server配置管理器 SQL Server Management Studio SQL Server Business Intellig ...

  2. MyBatis逆向工程无效

    在Taget目录下修改的东西无法逆向, 在源代码目录就可以

  3. Scrapy 教程(五)-分页策略

    scrapy 爬取分页网站的策略 1. 检测当前页是否存在“下一页” 2. 如果存在,把“下一页”的链接交给本方法或者其他方法 3. 如果不存在,结束 图示 示例代码 def parse(self, ...

  4. PCIe事务层の详解(一)

    PCIe总线的通信机制:当一个设备要想另一个设备进行读取通信时,请求方requester需要向另一个设备发送请求request,靶向方作为事件完成方completer,以complete Packet ...

  5. Distributed Deep Learning

    安利一下刘铁岩老师的<分布式机器学习>这本书 以及一个大神的blog: https://zhuanlan.zhihu.com/p/29032307 https://zhuanlan.zhi ...

  6. Windows 10 IoT Core Dashboard 无法安装的问题

    有人在answers.microsoft.com问这个问题,官方给了个这样的回答,然后还锁定了问题不让别人回复 您好, 了解到您在使用时遇到问题. 请您详细描述下您的操作,请问您是在打开安装程序还是在 ...

  7. HTML-图片和多媒体

    1.图片和多媒体 (1)    图片:img元素 src 属性:图片路径: alt 属性:图片无法显示时使用的替代文字: title:鼠标悬停时显示的文字 : <img src="图片 ...

  8. JS 的JSON对象

    知识点一: 循环对象 for(x in Obj)  x表示属性,Obj.x表示属性的值. 修改值 Obj.x = "  "//直接修改 删除对象属性 delete Obj.x va ...

  9. nohup - 使程序运行时不挂起, 不向 tty 输出信息

    总览 (SYNOPSIS) nohup COMMAND [ARG]... nohup OPTION 描述 (DESCRIPTION) 执行 COMMAND 命令, 忽略 hangup (挂起) 信号. ...

  10. Python字符串(str)方法调用

    # str# n = 'pianYU'# v = n.capitalize() # 将字符串的首字母大写# print(v)## n = 'pianYI'# v1 = n.isupper() # 判断 ...