yum安装高版本ruby
通过换yum源安装:
yum install centos-release-scl-rh
yum install rh-ruby23 -y
scl enable rh-ruby23 bash
ruby -v
另外可能出现一个错误:
ruby: error while loading shared libraries: libruby.so.2.3: cannot open shared object file: No such file or directory
这个错误的原因是这个so文件的目录不对。
cp /opt/rh/rh-ruby23/root/usr/lib64/libruby.so.2.3 /usr/lib64/
这样就可以正常使用ruby了。
oracle查看表空间物理文件路径及大小
sql语句如下:
SELECT
mAX(B.file_id) id,
B.TABLESPACE_NAME 表空间,
B.FILE_NAME 物理文件名,
B.BYTES / 1024 / 1024 大小M,
(B.BYTES - SUM(NVL(A.BYTES,0))) / 1024 / 1024 已使用M,
SUBSTR((B.BYTES - SUM(NVL(A.BYTES,0))) / (B.BYTES) * 100,1,5) 利用率
FROM DBA_FREE_SPACE A,DBA_DATA_FILES B
WHERE A.FILE_ID = B.FILE_ID
GROUP BY B.TABLESPACE_NAME,B.FILE_NAME,B.BYTES
ORDER BY B.TABLESPACE_NAME;
oracle查看表空间使用情况
sql如下:
select
a.a1 表空间名称,
c.c2 类型,
c.c3 区管理,
b.b2/1024/1024/1024 表空间大小G,
(b.b2-a.a2)/1024/1024/1024 已使用G,
substr((b.b2-a.a2)/b.b2*100,1,5) 已利用率,
round(100-(substr((b.b2-a.a2)/b.b2*100,1,5)), 3) 剩余利用率
from
(select tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,
(select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,
(select tablespace_name c1,contents c2,extent_management c3 from dba_tablespaces) c
where a.a1=b.b1 and c.c1=b.b1;
python获取json格式时间
脚本作用是从接口获取json数据并提取时间。
import requests
import json
url = 'http://192.168.0.5:8992/api/datetime'
ret = requests.get(url)
rs = json.loads(ret.text)['result']['datetime']
print (rs)
推荐python3运行该脚本。
接口获取数据如下:
{'c': 0, 'result': {'datetime': '2023-01-05 14:50:01'}}
执行结果:
seeyon@uos-PC:~$ python3 index.py
2023-01-05 14:50:01
python循环增加系统时间
代码的作用是按照对应的循环次数,每次给当前系统时间加上5秒。
import time
import datetime
import os
for num in range(1,50):
aftertime = (datetime.datetime.now() + datetime.timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S")
print('5S后时间:%s' % (aftertime))
os.system('date -s "%s"' % (aftertime))
print('这是第%s次循环' % (num))
time.sleep(3600)
推荐python3运行。
解决Cannot retrieve metalink for...
将epel源文件中的https转为http。
epel也正好支持http+https两种方式。
sed -i 's#https://#http://#g' /etc/yum.repos.d/epel*repo
问题解决了。