Cygwinで毎分bashスクリプトを実行します。

Cygwinで毎分bashスクリプトを実行します。

次のスクリプトがあり、Windowsサーバーで1分ごとに実行する必要があります。ファイルパスはd / TFTP / script.shなので、毎分バックグラウンドで実行されるようにwhileループなどを挿入できるかどうか疑問に思います。

#!/bin/bash

declare -A arr_map

arr_map=([AR]=Switches [SW]=Switches [LR]=Switches [AP]=Default [GV]=Default [DR]=Default [GV]=Default [VN]=Default [MGMT]=Default [GW]=Routers)

# Iterate through indexes of array
for keyword in "${!arr_map[@]}"; do
    # Search files containing the "-$keyword" pattern in the name
    # like "-GW" or "-AR". This pattern can be tuned to the better matching.
    for filename in *-"$keyword"*; do
        # if file exists and it is regular file
        if [ -f "$filename" ]; then
            destination=${arr_map["$keyword"]}/"$filename"
            # Remove these echo commands, after checking resulting commands.
            echo mkdir -p "$destination"
            echo mv -f "$filename" "$destination"
            mkdir -p "$destination"
            mv -f "$filename" "$destination"
            #echo in front of mkidr and move
        fi
    done
done

ベストアンサー1

各質問に対するコメントスレッド:

#!/bin/bash
while [[ 1 -eq 1 ]]; do
    everything_in_the_original_script
    sleep 60
done

おすすめ記事