王殊勋的个人博客

只要开始,虽远不迟!

该脚本可以记录python程序运行时间,并写入日志。 1 2 3 4 5 6 7 8 9 10 # coding=utf-8 # import time starttime = time.time() time.sleep(2.1) #延时2.1s,此处可以是任何python需要执行的代码 endtime = time.time() dtime = endtime - starttime filename = 'test_text.txt' with open(filename, 'w') as file_object: file_object.write('程序运行时间:%.8
阅读全文 »

该脚本可以查找某个目录里指定时间范围的文件,并保存目录结构复制到新的路径。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import os import datetime import shutil time_modify = str(datetime.date.today() - datetime.timedelta(days=1)) time_end = str(datetime.date.today()) path_src_web = "/opt/Seeyon/A8/base/
阅读全文 »

安装oracle的服务器这三个目录千万别删。 1 2 3 /tmp /usr/tmp /var/tmp 里面可能存在.oracle目录。 删除会导致oracle监听失败。 需要重建该目录。 1 2 mkdir /var/tmp/.oracle chown -R oracle:oinstall /var/tmp/.oracle 重启oracle并重启监听。
阅读全文 »

可以测试到某个服务器的某个端口的连通性。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #!/usr/bin/env python #-*-coding:GBK -*- import socket,sys,time,os,signal from ping3 import ping result = [] def Seeyon_write(result): filename = 'result.txt'
阅读全文 »

今天,装完一台redis,并配置好redis.conf后,想偷懒直接用scp传到另一台redis,省去全部重新编辑的麻烦。结果一执行就出现下面这个错误: 1 bash: scp: command not found 所有机器我都是最小化安装,所以很多组件没装也是情理之中,所以用yum装一下scp: 1 yum -y install openssh-clients 装完后,继续执行之前的命令,结果出现如下错误: 1 2 3 4 5 6 [root@cache-ns-4 etc]# scp redis.conf root@192.168.17.125:/usr/local
阅读全文 »

使用docker search来搜索镜像会返回500错误: 1 2 [root@localhost:~]# docker search idocker.io/hello-world Error response from daemon: Unexpected status code 500 因为平常不怎么使用搜索,而且Nexus前台也有镜像浏览页面,所以一直没花时间去解决。年前封网好不容易有点空闲,寻思着解决下。 经过定位,发现了问题所在:Nexus里面的Docker有3种类型仓库:group、hosted、proxy,也就是组合仓库、本地仓库和代理仓库,其中组合仓库就是本地仓库和
阅读全文 »

该程序是使用Python把sqlite的article表中的content字段全部由markdown转换为html。 首先安装依赖: 1 2 pip install sqlite3 pipinstall markdown 以下是程序主体: 1 2 3 4 5 6 7 8 9 10 11 12 import sqlite3 import markdown conn = sqlite3.connect('test.db') cursor = conn.cursor() for i in range(0,900): try: a = cursor.execute('select
阅读全文 »
0%