我来给你个例子
sudo -u root bash -c '#!/bin/bash
# 定义URL数组
urls=(
"url#1"
"url#2"
"url#3"
"url#4"
"url#5"
"url#6"
"url#7"
"url#8"
)
# 日志文件路径
LOG_FILE="/tmp/batch_url_access.log"
# 遍历数组中的每个URL并访问它
for url in "${urls[@]}"; do
echo "Accessing $url"
curl -s "$url" >> "$LOG_FILE" 2>&1
echo "Done."
done' |