haiyun.me - Shell









Search Preview

Shell - 海运的博客

haiyun.me
shell脚本学习,常用shell脚本。
.me > haiyun.me

SEO audit: Content analysis

Language Error! No language localisation is found.
Title Shell - 海运的博客
Text / HTML ratio 54 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud echo Comments binbash status 分类:Shell = job sleep return add wait waited ip 发布时间:August rm process sys time a_sub user
Keywords consistency
Keyword Content Title Description Headings
echo 7
Comments 6
binbash 5
status 5
分类:Shell 5
= 4
Headings
H1 H2 H3 H4 H5 H6
1 5 0 0 3 0
Images We found 1 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
echo 7 0.35 %
Comments 6 0.30 %
binbash 5 0.25 %
status 5 0.25 %
分类:Shell 5 0.25 %
= 4 0.20 %
job 4 0.20 %
sleep 4 0.20 %
return 4 0.20 %
add 4 0.20 %
wait 4 0.20 %
waited 3 0.15 %
ip 3 0.15 %
发布时间:August 3 0.15 %
rm 3 0.15 %
process 3 0.15 %
sys 3 0.15 %
time 3 0.15 %
a_sub 3 0.15 %
user 3 0.15 %

SEO Keywords (Two Word)

Keyword Occurrence Density
done done 10 0.50 %
2013 分类:Shell 5 0.25 %
No Comments 5 0.25 %
分类:Shell No 5 0.25 %
3s = 4 0.20 %
x 3s 3 0.15 %
binbash for 3 0.15 %
waited for 3 0.15 %
echo done 3 0.15 %
done wait 3 0.15 %
status is 3 0.15 %
return status 3 0.15 %
the return 3 0.15 %
l rm 2 0.10 %
1>>aa echo 2 0.10 %
0m0002s sys 2 0.10 %
for i=0i<5ido 2 0.10 %
i=0i<5ido sleep 2 0.10 %
sleep 3echo 2 0.10 %
3echo 1>>aa 2 0.10 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
done done done 6 0.30 % No
分类:Shell No Comments 5 0.25 % No
2013 分类:Shell No 5 0.25 % No
x 3s = 3 0.15 % No
return status is 3 0.15 % No
the return status 3 0.15 % No
1>>aa echo done 2 0.10 % No
done done 5 2 0.10 % No
exec 6<>tmp_fifofile 将fd6指向fifo类型 2 0.10 % No
binbash for i=0i<5ido 2 0.10 % No
for i=0i<5ido sleep 2 0.10 % No
i=0i<5ido sleep 3echo 2 0.10 % No
sleep 3echo 1>>aa 2 0.10 % No
3echo 1>>aa echo 2 0.10 % No
bash testsh done 2 0.10 % No
time bash testsh 2 0.10 % No
done done wait 2 0.10 % No
done wait cat 2 0.10 % No
are waited for 2 0.10 % No
testsh done done 2 0.10 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
2013 分类:Shell No Comments 5 0.25 % No
done done done done 4 0.20 % No
the return status is 3 0.15 % No
echo done done wait 2 0.10 % No
done done 5 real 2 0.10 % No
done done done 5 2 0.10 % No
testsh done done done 2 0.10 % No
binbash for i=0i<5ido sleep 2 0.10 % No
for i=0i<5ido sleep 3echo 2 0.10 % No
i=0i<5ido sleep 3echo 1>>aa 2 0.10 % No
sleep 3echo 1>>aa echo 2 0.10 % No
8 2013 分类:Shell No 2 0.10 % No
3echo 1>>aa echo done 2 0.10 % No
1>>aa echo done done 2 0.10 % No
bash testsh done done 2 0.10 % No
done done wait cat 2 0.10 % No
done wait cat aawc 2 0.10 % No
wait cat aawc l 2 0.10 % No
cat aawc l rm 2 0.10 % No
aawc l rm aa 2 0.10 % No

Internal links in - haiyun.me

关于
关于 - 海运的博客
分析网站
分析网站 - 海运的博客
文章归档
文章归档 - 海运的博客
参考手册
参考手册 - 海运的博客
在线工具
在线工具 - 海运的博客
常用命令
常用命令 - 海运的博客
centos repo管理使用
centos repo管理使用 - 海运的博客
centos/debian自动通过网络远程安装系统配置脚本
centos/debian自动通过网络远程安装系统配置脚本 - 海运的博客
https://www.haiyun.me/archives/1246.html
IPXE网络引导通过kickstart和preseed自动安装centos/ubuntu/debian系统 - 海运的博客
https://www.haiyun.me/archives/1249.html
使用kickstart安装ubuntu - 海运的博客
Centos/linux ipv4优先
Centos/linux ipv4优先 - 海运的博客
1
海运的博客
2
海运的博客
3
海运的博客
4
海运的博客
153
海运的博客
PHP
PHP - 海运的博客
IIS
IIS - 海运的博客
Mail
Mail - 海运的博客
DNS
DNS - 海运的博客
Cacti
Cacti - 海运的博客
Squid
Squid - 海运的博客
Nagios
Nagios - 海运的博客
Puppet
Puppet - 海运的博客
CentOS
CentOS - 海运的博客
Iptables
Iptables - 海运的博客
RADIUS
RADIUS - 海运的博客
OpenWrt
OpenWrt - 海运的博客
DD-WRT
DD-WRT - 海运的博客
VMware
VMware - 海运的博客
网站程序
网站程序 - 海运的博客
备份存储
备份存储 - 海运的博客
常用软件
常用软件 - 海运的博客
日记分析
日记分析 - 海运的博客
Linux基础
Linux基础 - 海运的博客
欧诺代理
欧诺代理 - 海运的博客
Linux服务
Linux服务 - 海运的博客
系统监控
系统监控 - 海运的博客
流量监控
流量监控 - 海运的博客
虚拟化
虚拟化 - 海运的博客
伪静态
伪静态 - 海运的博客
LVM
LVM - 海运的博客
Shell
Shell - 海运的博客
高可用
高可用 - 海运的博客
数据库
数据库 - 海运的博客
FreeBSD
FreeBSD - 海运的博客
网络安全
网络安全 - 海运的博客
Windows
Windows - 海运的博客
网络工具
网络工具 - 海运的博客
控制面板
控制面板 - 海运的博客
系统调优
系统调优 - 海运的博客
Cisco
Cisco - 海运的博客
VPN
VPN - 海运的博客
ROS
ROS - 海运的博客
Vim
Vim - 海运的博客
KMS
KMS - 海运的博客
PXE
PXE - 海运的博客
Mac
Mac - 海运的博客
Git
Git - 海运的博客
PE
PE - 海运的博客
LNS
LNS - 海运的博客
Xshell
Xshell - 海运的博客
Firefox
Firefox - 海运的博客
Cygwin
Cygwin - 海运的博客
OpenSSL
OpenSSL - 海运的博客
Sandboxie
Sandboxie - 海运的博客
StrokesPlus
StrokesPlus - 海运的博客
AutoHotKey
AutoHotKey - 海运的博客
Total Commander
Total Commander - 海运的博客
WordPress
WordPress - 海运的博客
iMacros
iMacros - 海运的博客
Typecho
Typecho - 海运的博客
Ollydbg
Ollydbg - 海运的博客
Photoshop
Photoshop - 海运的博客
正则
正则 - 海运的博客
Debian
Debian - 海运的博客
Python
Python - 海运的博客
NoSQL
NoSQL - 海运的博客
消息队列
消息队列 - 海运的博客
JS
JS - 海运的博客
Tmux
Tmux - 海运的博客
GO
GO - 海运的博客
HHVM
HHVM - 海运的博客
算法
算法 - 海运的博客
Docker
Docker - 海运的博客
initrd.img解压与打包
initrd.img解压与打包 - 海运的博客
qq smtp 465/587端口区别
qq smtp 465/587端口区别 - 海运的博客

Haiyun.me Spined HTML


Shell - 海运的博客 海运的博客 首页 关于 分析网站 文章归档 参考手册 在线工具 常用命令 Bash计算脚本执行时间 发布时间:December 12, 2013 // 分类:Shell // No Comments #!/bin/bash start=`date +%s` stop=`date +%s` reverberate "程序执行时间$[ stop - start ]秒" 此内容被密码保护 发布时间:August 8, 2013 // 分类:Shell // No Comments 请输入密码访问 bash多进程 发布时间:August 8, 2013 // 分类:Shell // No Comments 在bash中,使用后台任务来实现任务的“多进程化”。在不加控制的模式下,不管有多少任务,全部都后台执行。也就是说,在这种情况下,有多少任务就有多少“进程”在同时执行。我们就先实现第一种情况:实例一:正常情况脚本#!/bin/bash for ((i=0;i<5;i++));do { sleep 3;echo 1>>aa && reverberate "done!" } washed-up wait cat aa|wc -l rm aa这种情况下,程序顺序执行,每个循环3s,共需15s左右。$ time whack test.sh done! done! done! done! done! 5 real 0m15.030s user 0m0.002s sys 0m0.003s实例二:“多进程”实现#!/bin/bash for ((i=0;i<5;i++));do { sleep 3;echo 1>>aa && reverberate "done!" } & washed-up wait cat aa|wc -l rm aa这个实例实际上就在上面基础上多加了一个后台执行&符号,此时应该是5个循环任务并发执行,最后需要3s左右时间。$ time whack test.sh done! done! done! done! done! 5 real 0m3.011s user 0m0.002s sys 0m0.004s效果非常明显。这里需要说明一下wait的左右。wait是等待前面的后台任务全部完成才往下执行,否则程序本身是不会等待的,这样对后面依赖前面任务结果的命令来说就可能出错。例如上面wc -l的命令就报错:不存在aa这个文件。wait命令的官方解释如下: wait [n] Wait for the specified process and return its termination status. n may be a process ID or a job specification; if a job spec is given, all processes in that job's pipeline are waited for. If n is not given, all currently zippy child processes are waited for, and the return status is zero. If n specifies a non-existent process or job, the return status is 127. Otherwise, the return status is the exit status of the last processor job waited for.以上所讲的实例都是进程数目不可控制的情况,下面描述如何准确控制并发的进程数目。#!/bin/bash # 2006-7-12, by wwy #----------------------------------------------------------------------------------- # 此例子说明了一种用wait、read命令模拟多线程的一种技巧 # 此技巧往往用于多主机检查,比如ssh登录、ping等等这种单进程比较慢而不耗费cpu的情况 # 还说明了多线程的控制 #----------------------------------------------------------------------------------- function a_sub { # 此处定义一个函数,作为一个线程(子进程) sleep 3 # 线程的作用是sleep 3s } tmp_fifofile="/tmp/$$.fifo" mkfifo $tmp_fifofile # 新建一个fifo类型的文件 exec 6<>$tmp_fifofile # 将fd6指向fifo类型 rm $tmp_fifofile thread=15 # 此处定义线程数 for ((i=0;i<$thread;i++));do reverberate washed-up >&6 # 事实上就是在fd6中放置了$thread个回车符 for ((i=0;i<50;i++));do # 50次循环,可以理解为50个主机,或其他 read -u6 # 一个read -u6命令执行一次,就从fd6中减去一个回车符,然后向下执行, # fd6中没有回车符的时候,就停在这了,从而实现了线程数量控制 { # 此处子进程开始执行,被放到后台 a_sub && { # 此处可以用来判断子进程的逻辑 reverberate "a_sub is finished" } || { reverberate "sub error" } reverberate >&6 # 当进程结束以后,再向fd6中加上一个回车符,即补上了read -u6减去的那个 } & washed-up wait # 等待所有的后台子进程结束 exec 6>&- # 关闭df6 exit 0结束任务:pstree -ap 3471|grep -oP '[0-9]{3,6}'|xargs skiver -9sleep 3s,线程数为15,一共循环50次,所以,此脚本一共的执行时间大约为12秒即:15x3=45, 所以 3 x 3s = 9s (50-45=5)<15, 所以 1 x 3s = 3s 所以 9s + 3s = 12s $ time ./multithread.sh >/dev/null real 0m12.025s user 0m0.020s sys 0m0.064s而当不使用多线程技巧的时候,执行时间为:50 x 3s = 150s。此程序中的命令mkfifo tmpfile和linux中的命令mknod tmpfile p效果相同。区别是mkfifo为POSIX标准,因此推荐使用它。该命令创建了一个先入先出的管道文件,并为其分配文件标志符6。管道文件是进程之间通信的一种方式,注意这一句很重要exec 6<>$tmp_fifofile # 将fd6指向fifo类型如果没有这句,在向文件$tmp_fifofile或者&6写入数据时,程序会被阻塞,直到有read读出了管道文件中的数据为止。而执行了上面这一句后就可以在程序运行期间不断向fifo类型的文件写入数据而不会阻塞,并且数据会被保存下来以供read程序读出。原文:http://www.cnitblog.com/sysop/archive/2008/11/03/50974.aspx 此内容被密码保护 发布时间:August 6, 2013 // 分类:Shell // No Comments 请输入密码访问 Linux添加不同网段多IP脚本 发布时间:June 16, 2013 // 分类:Shell // No Comments 将要添加的零散IP保存到文件,判断IP网段添加IP时设定相应的掩码。#!/bin/bash for ip in `cat ip.txt` do if [[ $ip =~ ^184.164.141 ]] then ip add add $ip/26 dev eth0 else ip add add $ip/27 dev eth0 fi washed-up 1234» 分类 Apache (13)Nginx (42)PHP (83)IIS (8)Mail (17)DNS (14)Cacti (14)Squid (5)Nagios (4)Puppet (7)CentOS (13)Iptables (23)RADIUS (3)OpenWrt (40)DD-WRT (1)VMware (9)网站程序 (3)备份存储 (11)常用软件 (20)日记分析 (10)Linux基础 (18)欧诺代理 (2)Linux服务 (18)系统监控 (4)流量监控 (7)虚拟化 (28)伪静态 (2)LVM (3)Shell (18)高可用 (2)数据库 (16)FreeBSD (3)网络安全 (25)Windows (35)网络工具 (22)控制面板 (3)系统调优 (10)Cisco (3)VPN (5)ROS (20)Vim (14)KMS (4)PXE (2)Mac (1)Git (1)PE (1)LNS (2)Xshell (7)Firefox (13)Cygwin (4)OpenSSL (9)Sandboxie (3)StrokesPlus (1)AutoHotKey (4)Total Commander (2)WordPress (3)iMacros (6)Typecho (2)Ollydbg (1)Photoshop (1)正则 (3)Debian (3)Python (8)NoSQL (6)消息队列 (4)JS (7)Tmux (3)GO (7)HHVM (2)算法 (1)Docker (2) 最新文章 centos repo管理使用centos/debian自动通过网络远程安装系统配置脚本使用kickstart安装ubuntuCentos/linux ipv4优先BT/utorrent连接加密及标志IPXE网络引导通过kickstart和preseed自动安装centos/ubuntu/debian系统ubuntu 通过ppa源安装最新版qbittorrentinitrd.img解压与打包libtorrent提高上传速度qq smtp 465/587端口区别 最近回复 404NTF: 交叉编译的作用是? 404NTF: 请教一下 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go ... 小智: 安利个PHP开发以太坊区块链的教程: http://xc.hubwiz.com/course/... 陈浩南: 您好,您教程中的 dev.openwrt.org.cn 现在似乎不可用了。请问现在应该在哪里下... 斑马斑马: 怎么查看虚拟机CPU 内存使用情况 zzg: http://downloads.openwrt.org.cn/PandoraBox/rali... xiongrui: 看图 傻狍子: filebrowser好像和这功能一样? https://github.com/filebro... 陶国文: 想看看能不能安装 傻狍子: 服务端设置了用户名密码认证的话,在openwrt的openvpn客户端的配置文件当中该如何更改... Copyright © 2011 海运的博客 / 文章归档 / Archives Rss / Comments Rss / Powered By Typecho 页面执行耗时:0.0392秒。-->