记录一下,部分工作中首次遇到的小问题,当时却花费了很多时间去解决的东西。
- linux批量关键词删除文件
find /data/work/ptop/ -name '*_201810*' |xargs rm -rf
- python调用cx_Oracle包时,定时器不起作用,原因:cx_Oracle需要依赖oracle的ORACLE_HOME环境。环境变量定义时,ORACLE_HOME定义在/etc/profile下,在这里修改的内容是对所有用户起作用的,但是对crontab是不起作用,解决方式:crontab中添加ORACLE_HOME路径:
0 7 * * * . /etc/profile; /usr/bin/python /data/ptop/online.py >>/data/ptop/online.log 2>&1
- linux后台运行python代码时,log缓存,不能立刻输出:加 “-u”即可。
nohup python -u ptop_online.py >> ptop_online.log 2>&1 &
- linux用户权限限制,进入root用户操作:
sudo -i
- 查看mysql数据库、表大小,对应修改表名及数据库名即可,也可转换单位:
select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') table_space
from information_schema.tables
where table_schema='data_summary' AND table_name='user_detail_info';
- windows下设置定时器:
schtasks参数设置参考链接:参考url
//首先创建.bat文件
// schtasks命令创建定时器
schtasks /create /sc minute /mo 1 /tn "RunPerOneMinuts" /tr E:\update_file_bj.bat //创建
schtasks /delete /tn RunPerOneMinuts /f//删除
- win10系统 64位 查看pip支持的文件名及版本,解决.whl is not a supported wheel on this platform问题:
import pip._internal
print(pip._internal.pep425tags.get_supported())