Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- log_file=/var/log/curl_error.log
- max_age=86400 # one day in seconds
- max_loop=1000 # maximum number of loops to execute
- loop_count=0 # current number of loops executed
- if [ ! -f "$log_file" ]; then
- touch "$log_file"
- fi
- while [ $loop_count -lt $max_loop ]; do
- if ! curl -sSf https://downloads.wordpress.org/ | grep -q 'nginx'; then
- current_time=$(date '+%Y-%m-%d %H:%M:%S')
- echo "Error: $current_time" >> "$log_file"
- fi
- sleep 2
- loop_count=$((loop_count+1))
- if [ $(($(date +%s) - $(date -r "$log_file" +%s))) -ge $max_age ]; then
- mv "$log_file" "$log_file.old"
- touch "$log_file"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement