本帖最后由 newswan 于 2024-8-16 20:12 编辑
- #!/bin/bash
-
- time_target="2300"
-
- time_current=$(date +%H%M)
- timestamp_current=$(date +%s)
-
- if [[ $time_current -gt $time_target ]]; then
- timestamp_target=$(date -d "tomorrow 23:00:00" +%s)
- else
- timestamp_target=$(date -d "today 23:00:00" +%s)
- fi
-
- wait_seconds=$((timestamp_target - timestamp_current))
-
- echo "wait:$wait_seconds 秒"
- sleep $wait_seconds
- echo "23:00"
- find "/path" -type f -mtime +10 -delete
复制代码
|