I have this txt files that contains IPs, one per line of file, that I want to block using ipset.
I have this bash script that essentially reads from the plain txt file and constructs an array. Then it iterates the array elements and add each one to the ipset I have created for that purpose.
The problem is this: if I execute the script manually from the terminal, it works perfectly, but when I add the script to run periodically using crontab, the script runs but the IPs are not added to the ipset.
This is the relevant part of the script.
index=0 while true; do ipset -quiet -A myIpset $[arrayOfIPS[$index]} index=$[$index + 1] if [ "$index" -gt "$lastIndexOfArray" ]; then break fi done
This works perfectly from terminal but not running from a crontab task. why?