I have the following script and I need this to run every minute on my windows server. The file path is d/TFTP/script.sh so I was wondering if I can insert a while loop or some other method so I can have this running in the background every minute
#!/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
bash.exe
with arguments-c
and'cd /path/to/script; ./script.sh'
, and schedule it as desired.