Advertisement
Guest User

curl.sh

a guest
Apr 12th, 2023
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. log_file=/var/log/curl_error.log
  4. max_age=86400 # one day in seconds
  5. max_loop=1000 # maximum number of loops to execute
  6. loop_count=0 # current number of loops executed
  7.  
  8. if [ ! -f "$log_file" ]; then
  9. touch "$log_file"
  10. fi
  11.  
  12. while [ $loop_count -lt $max_loop ]; do
  13. if ! curl -sSf https://downloads.wordpress.org/ | grep -q 'nginx'; then
  14. current_time=$(date '+%Y-%m-%d %H:%M:%S')
  15. echo "Error: $current_time" >> "$log_file"
  16. fi
  17. sleep 2
  18. loop_count=$((loop_count+1))
  19. if [ $(($(date +%s) - $(date -r "$log_file" +%s))) -ge $max_age ]; then
  20. mv "$log_file" "$log_file.old"
  21. touch "$log_file"
  22. fi
  23. done
  24.  
Tags: curl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement