如果需要 shell 执行一些任务,可以写个脚本,直接使用
ansible all -i inventory.py -l 192.168.1.3 -m script -a show_ip.sh
如果需要 shell 执行一些任务,可以写个脚本,直接使用
ansible all -i inventory.py -l 192.168.1.3 -m script -a show_ip.sh
直接输出
stat -c %Y filename
学习《计算机操作系统》
引入进程,就是为了多个程序能够并发执行。提高系统资源利用率,增加系统吞吐量。进程是指在系统中能独立运行并作为资源分配的基本单位,它是由一组机器指令,数据和堆栈组成的,是一个能独立运行的活动实体。由于进程拥有自己的资源,故使调度付出的开销较大。
引入线程,线程是比进程更小的单位,在一个进程中可以包含若干个线程,它们可以利用进程所拥有的资源。在引入线程的 OS 中,通常都是把进程作为分配资源的基本单位,而把线程作为独立运行和独立调度的基本单位。由于线程比进程更小,基本上不拥有资源,故对它的调度所付出的开销就会小得多,能更高效地提高系统内多个程序间并发执行的程度。
参考:
https://guides.github.com/features/mastering-markdown/
mac 下工具
sublime + markdown preview
curl 简单又强大,要好好学习。
test_output=/tmp/curl-test
test_times=3000
test_url="http://jpuyy.com/wp-content/uploads/2012/03/bg.gif"
for i in $(seq 1 $test_times);
do curl -o /dev/null -s -w 'time_namelookup:%{time_namelookup} time_connect:%{time_connect} time_appconnect:%{time_appconnect} time_pretransfer:%{time_pretransfer} time_redirect:%{time_redirect} time_starttransfer:%{time_starttransfer} time_total:%{time_total}' $test_url >> $test_output 2>&1
echo >> $test_output
done
按总时间(最后一段)排序,取出 10 次用时最长的访问
cat /tmp/curl-test | sort -k 7 | tail -n 10
服务器上到底花了多少时间呢
time_starttransfer - time_pretransfer
保存一个 format 文件
\n
url_effective: %{url_effective}\n
http_code: %{http_code}\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
num_connects: %{num_connects}\n
num_redirects: %{num_redirects}\n
----------\n
time_total: %{time_total}\n
\n
size_download: %{size_download}\n
size_header: %{size_header}\n
size_request: %{size_request}\n
curl 请求的时候加 -w @curl-format 调用此格式
--resolve file.jpuyy.com:443:10.10.5.11
测试 http 和 https latency
https://sking7.github.io/articles/44961356.html
1~9的9个数字, 每个数字只能出现一次, 要求这样的9位数:其第一位能被1整除, 前两位能被2整除, 前三位能被3整除…依次类推,前9位能被9整除。所有的9位数中,只有一个数字满足这些条件,请你输出这个9位数。
思路:
根据描述写出函数,判断重复,缩小范围
#!/usr/bin/env python
#-*- coding:utf-8 -*-
def no_repeat(my_num):
uniq_str=''.join(set(str(my_num)))
if len(str(my_num)) == len(uniq_str):
return True
def possible(prefix):
possible_list = []
number_len = len(str(prefix)) + 1
for i in range(10*prefix + 1, 10*(prefix+1)):
if (i % number_len == 0) and no_repeat(i) and (number_len<9):
possible(i)
elif (i % number_len == 0) and no_repeat(i) and number_len == 9:
print i
def main():
for i in range(1,10):
possible(i)
if __name__ == "__main__":
main()