diff --git a/ubuntu_services/frpc.service b/ubuntu_services/frpc.service new file mode 100644 index 0000000..37a6a9b --- /dev/null +++ b/ubuntu_services/frpc.service @@ -0,0 +1,15 @@ +[Unit] +Description=Frp Client Service +After=network.target + +[Service] +Type=simple +User=nobody +Restart=on-failure +RestartSec=5s +ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini +ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini +LimitNOFILE=1048576 + +[Install] +WantedBy=multi-user.target diff --git a/ubuntu_services/readme.md b/ubuntu_services/readme.md index 97b0d6e..fb7300b 100644 --- a/ubuntu_services/readme.md +++ b/ubuntu_services/readme.md @@ -1 +1,8 @@ -service文件应该放在 /etc/systemd/system 目录下 \ No newline at end of file +service文件应该放在 /etc/systemd/system 目录下 + +服务安装 +cp ./aa.service /etc/systemd/system +systemctl daemon-reload +systemctl enable aa + + diff --git a/ubuntu_services/rtspSave.sh b/ubuntu_services/rtspSave.sh index 6578c4a..5cee9bf 100644 --- a/ubuntu_services/rtspSave.sh +++ b/ubuntu_services/rtspSave.sh @@ -1,6 +1,23 @@ -#!/bin/sh +#!/bin/bash + while true; do - ffmpeg -rtsp_transport tcp -stimeout 5000000 -i "rtsp://admin:user_123@192.168.31.64:554" -vcodec copy -t 500 -f segment -segment_time 1200 -segment_format mp4 -strftime 1 "/root/records/output_%Y-%m-%d_%H-%M.mp4" + # 获取当前日期,格式为 YYYY-MM 和 YYYY-MM-DD + TODAY_YM=$(date +%Y-%m) + TODAY_YMD=$(date +%Y-%m-%d) + + # 设置父目录的路径,你可以根据需要修改这个路径 + PARENT_DIR="/data1/records" + + # 构建完整的目录路径 + TARGET_DIR="${PARENT_DIR}/${TODAY_YM}/${TODAY_YMD}" + + # 检查今天的日期文件夹是否存在 + if [ ! -d "$TARGET_DIR" ]; then + # 如果不存在,创建该文件夹 + mkdir -p "$TARGET_DIR" + fi + + ffmpeg -rtsp_transport tcp -stimeout 5000000 -i "rtsp://admin:user_123@192.168.31.64:554" -vcodec copy -t 500 -f segment -segment_time 120 -segment_format mp4 -strftime 1 "/data1/records/%Y-%m/%Y-%m-%d/output_%Y-%m-%d_%H-%M.mp4" echo "Stream disconnected, reconnecting..." sleep 1 done