美文网首页
2020-07-16常用有趣命令之shell管理

2020-07-16常用有趣命令之shell管理

作者: 阿乜太帅 | 来源:发表于2020-07-16 19:23 被阅读0次

1.进程的批量kill

ps -ef |grep -v "root"|grep  "keyword"|awk '{print $2}'|xargs kill -9

2.进程并行化之软件

软件一:ParaFly:
https://github.com/ParaFly/ParaFly

示例,用服务器一半CPU运行程序:

echo "ls ~
df
ls -lh ~/bin" > bashfile
cpus=$( ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w |awk '{print $1/2}')
ParaFly -c bashfile -CPU $cpus

# Usage: ParaFly (opts)
# Required:
#   -c <str>              :filename containing list of bash-style commands to execute.
#   -CPU <int>            :number_of_threads
#
# Optional:
#   -shuffle              :randomly shuffles the command order.
#   -failed_cmds <str>    :filename to capture failed commands.  default("FailedCommands")
#   -v                    :simple progress monitoring.
#   -vv                   :increased verbosity in progress monitoring.

软件二:parallel
官网
Linux下的并行神器——parallel

软件三:pwait
https://github.com/wting/pwait or https://github.com/diazona/pwait

3.bash最简单的并行化--- 后台运行& + wait函数

#串行执行,耗时30秒
for ((i=1;i<=3;i++));do 
  { 
    sleep 3
    echo "Job $i is DONE"
  }
done

#并行执行,耗时3秒
for ((i=1;i<=3;i++));do 
  { 
    sleep 3
    echo "Job $i is DONE"
  } &
done
wait

相关文章

  • 2020-07-16常用有趣命令之shell管理

    1.进程的批量kill 2.进程并行化之软件 软件一:ParaFly:https://github.com/Par...

  • Shell指令

    什么是Shell指令 就是Linux命令(注:后期使用这些命令管理Linux操作系统) 常用的Shell指令 显示...

  • Linux基础命令 2

    1、Linux上的文件管理命令有哪些以及常用方法shell:shell负责接收用户输入的命令并进行解释,将需要执行...

  • systemd服务管理,编写systemd Unit文件

    熟悉systemctl常用命令 通过systemd管理shell脚本 通过systemd管理Nginx服务 熟悉s...

  • Shell命令汇总

    1、一般常用命令 (1)Shell 常用命令总结 (2)Shell的18条常用命令整理 2、文件操作常用命令 (1...

  • Linux命令学习之:echo命令

    Linux命令学习之:echo命令 简介 linux的echo命令, 在shell编程中极为常用, 在终端下打印变...

  • 几个shell

    Shell命令 1、文件管理.常用命令 ls: 列出目录 cd:切换目录 pwd:显示目前的目录 mkdir:创建...

  • Shell脚本

    shell脚本学习笔记 shell命令的组合运用 常用命令组合

  • adb shell uiautomator 命令

    adb shell uiautomator 命令 Tags: adb_shell 常用到的命令: uiautoma...

  • Linux 命令行

    Shell 文件管理命令行(一)Shell 文件操作 Shell 系统管理命令行(二)Shell 系统管理 ADB...

网友评论

      本文标题:2020-07-16常用有趣命令之shell管理

      本文链接:https://www.haomeiwen.com/subject/mhymhktx.html