CentOS 5.4
(in my script file – script.sh)
#!/bin/bash
ssh 192.168.0.1 'iptables -L' > /tmp;
(in /etc/crontab)
30 21 30 9 * root /bin/bash /script.sh
If I run the script in terminal, things work just fine. But use crontab to run it, the tmp will be generated, but there's nothing in the tmp file (0k). I already run ssh agent so ssh won't prompt to ask password. What could be the problem with this? Thanks.
Best Answer
I suggest you to always explicitly set all needed variables at the beginning of the scripts.
That said, I would
Now try the connection with
Edit: I guessed that the "iptables" command had to be executed by root on the remote server. If it is not, of course the "-l" parameter has to be changed accordingly.