解决aarch64架构redis无法正常启动
启动redis日志报错:
Redis will now exit to prevent data corruption. Note that it is possible to suppress this warning by setting the following config: ignore-warnings ARM64-COW-BUG
解决办法:
取消redis.conf配置文件中的最后一行注释:
ignore-warnings ARM64-COW-BUG
再次重启redis,问题解决。
安卓手机登录旧版本微信的方法
首先安装最新版本微信,然后通过adb执行如下命令卸载当前微信并保留应用数据:
adb shell pm uninstall -k --user 0 com.tencent.mm
然后通过adb安装旧版本微信:
adb install C:\Users\baoli\Downloads\7.0.22.apk
不需要登录就直接进入老版本微信了。
匹配一个文件最后500行并判断是否包含指定关键字
推荐Python3运行该脚本:
def get_last_lines(file_path, n):
with open(file_path, 'r') as f:
lines = f.readlines()
return lines[-n:]
result=[]
for key in get_last_lines("/opt/Seeyon/A8/ApacheJetspeed/logs/catalina.out", 500):
if "Java heap space" in key:
result.append('Error')
else:
result.append('Normal')
if "Error" in result:
print ("Error")
else:
print ("Normal")
Python检查网站打开状态
脚本首先会尝试获取网页内容,然后判断网页内容是否包含指定内容,然后判断网页状态码,都没问题就通过,其他情况全部发邮件告警。
import requests
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def send_email_smtp():
for receiver_email in ["dov@qq.com","27895@qq.com","416@qq.com"]:
sender_email = "dov@qq.com"
password = "*****************"
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = "服务器故障"
body = "协同网页信息获取失败,请重启应用系统!"
message.attach(MIMEText(body, "plain"))
try:
server = smtplib.SMTP("smtp.qq.com", 587)
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message.as_string())
print("Email sent successfully!")
except Exception...
Python找出3天前的备份压缩后删除
脚本会自动遍历目录找出时间戳距今超过3天的文件压缩,然后删除源文件。
import os
from datetime import datetime
import zipfile
#压缩文件
def create_zip(file, output_filename):
with zipfile.ZipFile(output_filename, 'w') as zipf:
zipf.write(file)
#找出日期小于当前日期三天的文件压缩并删除
def dbtar(directory, suffix):
files = []
for root, dirs, filenames in os.walk(directory):
for filename in filenames:
if filename.endswith(suffix):
files.append(os.path.join(root, filename))
for file in files:
times = abs(datetime.now()-datetime.fromtimestamp(os.path.getmtime(file))).days
if times > 2:
create_zip(file,file+".zip")
os.remove(file)
print ("操作完成!")
dbtar('/opt/backup/db','.dmp')
推荐python3执行该脚本。
centos7报错gcc: error trying to exec...
原因分析:
导致问题的原因可能是因为没有安装 g++,也可能是已安装的 gcc 和 g++ 版本号不一致不兼容导致。
解决方法:
yum install gcc-c++