mqtt
This commit is contained in:
parent
f5c5e6945c
commit
653e340758
2
MQTT.py
2
MQTT.py
|
@ -29,6 +29,8 @@ class MQTT:
|
|||
# git更新项目和配置文件
|
||||
update()
|
||||
client.publish('success', payload='update success', qos=0)
|
||||
elif data == "record":
|
||||
get_record(msg)
|
||||
else:
|
||||
client.publish('error', payload='No Such Type', qos=0)
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 设置文件保留时间为2天
|
||||
DAYS=2
|
||||
|
||||
# 使用find命令查找所有符合条件的文件
|
||||
find /home/pi/mp4 -type f -mtime +$DAYS -exec rm -f {} \;
|
||||
|
|
@ -4,13 +4,11 @@ set -e
|
|||
folder="/home/pi/mp4"
|
||||
|
||||
# 获取文件夹的大小
|
||||
size=$(du -sh "$folder" | awk '{print int($1/1024/1024)}')
|
||||
echo $size
|
||||
size=$(du -sh "$folder" | awk '{print int($1/1024/1024)}')
|
||||
while [[ $size -gt 24 ]]
|
||||
do
|
||||
# 获取最早创建的文件
|
||||
oldest_file=$(ls -tr | head -1 | xargs)
|
||||
echo $oldest_file
|
||||
rm -f $oldest_file
|
||||
size=$(du -sh "$folder" | awk '{print int($1/1024/1024)}')
|
||||
if [[ $size -le 24 ]]
|
||||
|
|
5
tool.py
5
tool.py
|
@ -12,9 +12,12 @@ def close_stream():
|
|||
|
||||
def exec_sh(msg):
|
||||
cmd = json.loads(msg.payload.decode('utf-8'))["data"]
|
||||
|
||||
subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
|
||||
def update():
|
||||
subprocess.Popen(['/bin/bash update.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
|
||||
def get_record(msg):
|
||||
time = json.loads(msg.payload.decode('utf-8'))["data"]
|
||||
|
|
Loading…
Reference in New Issue