摘要:
每次启动一个新shell时,bash shell都会运行.bashrc文件。可以这样来验证:在主目录下 的.bashrc文件中加入一条简单的echo语句,然后启动一个新shell。 不是所有 的发行版中都包含这些启动文件。基本上,依照下列顺序所找到的第一个文件会被运行,其余的 文件会被忽略: $HO
阅读全文
posted @ 2020-11-30 23:07
anobscureretreat
阅读(554)
推荐(0)
摘要:
at命令允许指定Linux系统何时运行脚本。at命令会将作业提交到队列中,指定shell何时运 行该作业。at的守护进程atd会以后台模式运行,检查作业队列来运行作业。大多数Linux发行 版会在启动时运行此守护进程。 atd守护进程会检查系统上的一个特殊目录(通常位于/var/spool/at)来
阅读全文
posted @ 2020-11-30 22:32
anobscureretreat
阅读(436)
推荐(0)
摘要:
有时你想改变系统上已运行命令的优先级。这正是renice命令可以做到的。它允许你指定 运行进程的PID来改变它的优先级。 renice命令有一些限制:1.只能对属于你的进程执行renice;2.只能通过renice降低进程的优先级;3.root用户可以通过renice来任意调整进程的优先级。如果想完
阅读全文
posted @ 2020-11-30 22:03
anobscureretreat
阅读(205)
推荐(0)
摘要:
在多任务操作系统中(Linux就是),内核负责将CPU时间分配给系统上运行的每个进程。调 度优先级(scheduling priority)是内核分配给进程的CPU时间(相对于其他进程)。在Linux系统 中,由shell启动的所有进程的调度优先级默认都是相同的。调度优先级是个整数值,从-20(最高
阅读全文
posted @ 2020-11-30 18:48
anobscureretreat
阅读(283)
推荐(0)
摘要:
因为该作业是默认作业(从加号可以看出),只需要使用bg命令就可以将其以后台模式重启。 注意,当作业被转入后台模式时,并不会列出其PID。如果有多个作业,你得在bg命令后加上作业号。 $ ./test11.sh ^Z [1]+ Stopped ./test11.sh $ ./test12.sh ^Z
阅读全文
posted @ 2020-11-30 17:18
anobscureretreat
阅读(284)
推荐(0)
摘要:
会话中启动shell脚本,然后让脚本一直以后台模式运行到结束,即使你退 出了终端会话。这可以用nohup命令来实现。 code macname@MacdeMacBook-Pro Desktop % cat test.sh #!/bin/bash # Trapping the script exit
阅读全文
posted @ 2020-11-30 16:28
anobscureretreat
阅读(928)
推荐(0)
摘要:
jobs命令可以查看分配给shell的作业。jobs命令会显示已停止/运行中的作业,以及 它们的作业号和作业中使用的命令。 code macname@MacdeMacBook-Pro Desktop % cat test.sh #!/bin/bash # Trapping the script ex
阅读全文
posted @ 2020-11-30 16:24
anobscureretreat
阅读(160)
推荐(0)
摘要:
本例中用到的trap命令会在每次检测到SIGINT信号时显示一行简单的文本消息。捕获这些信号会阻止用户用bash shell组合键Ctrl+C来停止程序 code macname@MacdeMacBook-Pro Desktop % cat test.sh #!/bin/bash # Testing
阅读全文
posted @ 2020-11-30 15:23
anobscureretreat
阅读(171)
推荐(0)
摘要:
code1 macname@localhost Desktop % macname@localhost Desktop % cat test.sh #!/bin/bash echo "Start the test script" count=1 while [ $count -le 5 ] do e
阅读全文
posted @ 2020-11-30 15:17
anobscureretreat
阅读(170)
推荐(0)
摘要:
在终端会话中使用后台进程时一定要小心。注意,在ps命令的输出中,每一个后台进程都和终端会话(pts/0)终端联系在一起。如果终端会话退出,那么后台进程也会随之退出。 $ ./test6.sh & [1] 3568 $ This is Test Script #1 $ ./test7.sh & [2]
阅读全文
posted @ 2020-11-30 15:08
anobscureretreat
阅读(509)
推荐(0)
摘要:
code from queue import Queue from threading import Thread # 用来表示终止的特殊对象 _sentinel = object() # A thread that produces data def producer(out_q): for i
阅读全文
posted @ 2020-11-29 21:05
anobscureretreat
阅读(168)
推荐(0)
摘要:
code from queue import Queue from threading import Thread class Producer(Thread): def __init__(self, q): super().__init__() self.count = 5 self.q = q
阅读全文
posted @ 2020-11-29 21:00
anobscureretreat
阅读(173)
推荐(0)
摘要:
code import multiprocessing from multiprocessing import Pool,Queue import time import threading import gevent from gevent import monkey monkey.patch_a
阅读全文
posted @ 2020-11-29 20:38
anobscureretreat
阅读(112)
推荐(0)
摘要:
python中Queue是消息队列,提供线程间通信机制,python3中重名为为queue Queue模块中的类:Queue(maxsize=0):创建一个FIFO队列,若给定最大值,队列没有空间时阻塞,否则是无限队列LifoQueue(maxsize=0):创建一个栈,maxsize含义同上Pri
阅读全文
posted @ 2020-11-29 20:29
anobscureretreat
阅读(416)
推荐(0)
摘要:
code import threading import time from queue import Queue def test(data,que,index): for i in data: if(i==8900): que.put(i) print(index," ",i) pass if
阅读全文
posted @ 2020-11-29 20:13
anobscureretreat
阅读(247)
推荐(0)
摘要:
code import multiprocessing from multiprocessing import Pool import time import threading g_num = 0 def test1(): for i in range(10): time.sleep(1) pri
阅读全文
posted @ 2020-11-29 20:00
anobscureretreat
阅读(238)
推荐(0)
摘要:
code import time import threading class MyCounter(threading.Thread): """自定义线程类型,继承threading.Thread类""" # 类属性 num = 1 def run(self): """重写run方法,在线程star
阅读全文
posted @ 2020-11-29 19:57
anobscureretreat
阅读(146)
推荐(0)
摘要:
code import gevent,time from gevent import monkey monkey.patch_all() #gevent三行放在其他所有import语句之前可以避免出现警告或者报错信息,导致程序不能正常运行 def test1(): for i in range(10
阅读全文
posted @ 2020-11-29 19:54
anobscureretreat
阅读(111)
推荐(0)
摘要:
code """ 守护线程:一个子线程,会随着主线程的退出直接退出 不论子线程中是否执行完成 不离不弃,死生相随 """ import threading import time def test(): while True: print(f"{threading.current_thread().
阅读全文
posted @ 2020-11-29 11:01
anobscureretreat
阅读(366)
推荐(0)
摘要:
code macname@MacdeMBP Desktop % macname@MacdeMBP Desktop % cat test.py import time from multiprocessing import Process def func(name, sec): print(name
阅读全文
posted @ 2020-11-28 23:19
anobscureretreat
阅读(285)
推荐(0)
摘要:
code macname@MacdeMBP Desktop % macname@MacdeMBP Desktop % cat test.py import time from multiprocessing import Process def func(name): print(f"我是{name
阅读全文
posted @ 2020-11-28 23:18
anobscureretreat
阅读(163)
推荐(0)
摘要:
code1 macname@MacdeMBP Desktop % egrep dog emp.fmt 2 第二条 dog 1800 90-uwuwuwu macname@MacdeMBP Desktop % cat emp.fmt 1 第一条 cat 1800 90-uwuwuwu 2 第二条 do
阅读全文
posted @ 2020-11-28 14:52
anobscureretreat
阅读(182)
推荐(0)
摘要:
code macname@localhost Desktop % cat exce.py import sys def tmp_func(): print(sys._getframe().f_code.co_name) tmp_func() macname@localhost Desktop % p
阅读全文
posted @ 2020-11-27 19:15
anobscureretreat
阅读(641)
推荐(0)
摘要:
code import time import datetime t1=time.time() time.sleep(0.02) t2=time.time() print("相差",(datetime.datetime.fromtimestamp(t2)-datetime.datetime.from
阅读全文
posted @ 2020-11-27 19:13
anobscureretreat
阅读(2836)
推荐(0)
摘要:
code import json new_dict={"func_name":"https://www.cnblogs.com/bigberg/p/6430095.html"} with open("record.json","w") as f: json.dump(new_dict,f) with
阅读全文
posted @ 2020-11-27 19:12
anobscureretreat
阅读(192)
推荐(0)
摘要:
code macname@localhost Desktop % cat content fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the
阅读全文
posted @ 2020-11-26 22:20
anobscureretreat
阅读(262)
推荐(0)
摘要:
code macname@localhost Desktop % cat content fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the
阅读全文
posted @ 2020-11-26 22:18
anobscureretreat
阅读(757)
推荐(0)
摘要:
code macname@localhost Desktop % macname@localhost Desktop % cat content fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the
阅读全文
posted @ 2020-11-26 22:15
anobscureretreat
阅读(1225)
推荐(0)
摘要:
code macname@localhost Desktop % cat content fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the lazy dog. fox jumps over the
阅读全文
posted @ 2020-11-26 21:42
anobscureretreat
阅读(168)
推荐(0)
摘要:
code #官网网址 https://www.iiyouu.com/hgsite/download/index.html #下载源码包 https://www.mercurial-scm.org/release/mercurial-5.6.tar.gz #解压 tar -xvf mercurial-
阅读全文
posted @ 2020-11-26 11:24
anobscureretreat
阅读(536)
推荐(0)
摘要:
code macname@localhost Desktop % cat test.sh my_array[0]=A my_array[1]=B my_array[2]=C my_array[3]=D echo "数组的元素为: ${my_array[*]}" echo "数组的元素为: ${my_
阅读全文
posted @ 2020-11-25 21:11
anobscureretreat
阅读(2472)
推荐(0)
摘要:
code macname@localhost Desktop % cat a.txt 1dededede 2dedefrfr 3frhvfvfvf 4frfrdede 5frfrfrfrf 6frfrede 7jukitttt 8csxssss 9zaxss 10swwww 11ssssss 12a
阅读全文
posted @ 2020-11-25 21:09
anobscureretreat
阅读(1187)
推荐(0)
摘要:
code macname@localhost Desktop % echo `uname -a` Darwin localhost 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141
阅读全文
posted @ 2020-11-25 21:07
anobscureretreat
阅读(436)
推荐(0)
摘要:
code macname@localhost Desktop % cat test.sh while read line;do echo $line; done < a.txt macname@localhost Desktop % macname@localhost Desktop % cat a
阅读全文
posted @ 2020-11-25 21:04
anobscureretreat
阅读(946)
推荐(0)
摘要:
code macname@localhost Desktop % echo file{1,2,3,4,5} file1 file2 file3 file4 file5 macname@localhost Desktop % macname@localhost Desktop %
阅读全文
posted @ 2020-11-25 21:02
anobscureretreat
阅读(729)
推荐(0)
摘要:
code macname@localhost Desktop % touch {aa,bb,cc}.txt macname@localhost Desktop %
阅读全文
posted @ 2020-11-25 20:59
anobscureretreat
阅读(165)
推荐(0)
摘要:
code macname@localhost Desktop % cat a.txt 1dededede 2dedefrfr 3frhvfvfvf 4frfrdede 5frfrfrfrf 6frfrede 7jukitttt 8csxssss 9zaxss 10swwww 11ssssss 12a
阅读全文
posted @ 2020-11-25 20:56
anobscureretreat
阅读(1762)
推荐(0)
摘要:
code macname@localhost Desktop % cat test.sh my_array[0]=A my_array[1]=B my_array[2]=C my_array[3]=D echo "数组元素个数为: ${#my_array[*]}" echo "数组元素个数为: ${
阅读全文
posted @ 2020-11-25 20:54
anobscureretreat
阅读(1627)
推荐(0)
摘要:
code macname@localhost ~ % logname macname macname@localhost ~ %
阅读全文
posted @ 2020-11-25 20:53
anobscureretreat
阅读(418)
推荐(0)
摘要:
code macname@localhost Desktop % zip -qr html.zip 资料 macname@localhost Desktop %
阅读全文
posted @ 2020-11-25 20:52
anobscureretreat
阅读(158)
推荐(0)