Problem executing commandline from script via cron
I am having trouble executing the iptables list commandline below within a script. When I execute the script within the /etc/SSH404Block/ folder as ./SSH404Block.sh, the iptables list is placed correctly into the temp2b.txt file. If I try to execute the SSH404Block.sh with the Cronjob line below, the iptables list is missing and the file will be empty.
Any clues as to how to fix this? Thanks. filePath=/etc/SSH404Block iptables -L -n -v --line-numbers | sort -n -k9 > $filePath/temp2b.txt # get cur iptables Cronjob: */5 * * * * /etc/SSH404Block/SSH404Block.sh |
Hi,
the environment is pretty minimal for cron jobs, so setting the PATH to include /sbin/ or explicitly calling /sbin/iptables may be required. HTH, Evo2. |
^ He's correct.
One would accomplish this by including the following on the second line of the script: Code:
export PATH=$PATH:/sbin |
WOW! You are all life savers. I have been working on this all yesterday afternoon and this morning. The LQ system isn't sending me message notices for some reason so I didn't see your messages until I came back in to ask another question. I tried your suggestion and it worked. I would have never figured out this command - 'export PATH=$PATH:/sbin'.
Thanks much! |
All times are GMT -5. The time now is 06:28 PM. |