I have the below script to automatize with cron, but when i run it "./" its work, but on cron dosen't work.
I tried many things, like a change the sh to bash for cron. Variables on my script, etc...
#!/bin/bash
DATE=$(/bin/date +%d-%m-%Y-%H-%M-%S)
USERFW="xxxx"
IPSERVER=$(ip route get 1.2.3.4 | awk '{print $7}')
for SW in `more fw.txt `
do
/usr/bin/sshpass -p "Hs@Pr&v3nT!" /usr/bin/ssh -tt -o StrictHostKeyChecking=no $USERFW@$SW <<EOF
execute backup config tftp SW-$DATE $IPSERVER
exit
exit
EOF
done
I need this code working on crontab... does anyone help me?