Reputation: 1065
I use trick77's IP blacklist script to configure the firewall of my apache server and am able to run his script in terminal.
However, when assigning the bash script in ipset-blacklist to crontab, it will not run no matter what I do.
@daily /var/bash/update-blacklist.sh
Since I haven't done this sort of thing before, I believe that the PATH
of the bash script isn't set correctly... but again, I'm not sure.
I have seen others using a line such as PATH=/usr/bin:/bin:/usr/sbin:/sbin
to resolve problems involving the script's location, but, I don't exactly know what this does.
I set the location of the bash file to /var/bash
instead of /usr/bin
and I believe that this is throwing things off.
Pardon my lack of understanding. I really am a beginner when it comes to bash.
Any help is greatly appreciated.
Added echo here >> /tmp/update-blacklist.out
to top of update-blacklist.sh
and set cron to run it every minute (* * * * *
).
The file was successfully created.
Added type -p curl grep egrep ipset >> /tmp/update-blacklist.out
to top of update-blacklist.sh
and returned:
-p: not found
curl is /usr/bin/curl
grep is /bin/grep
egrep is /bin/egrep
ipset: not found
Upvotes: 1
Views: 137
Reputation: 80931
The output from type ipset
indicated that ipset
was not in the cron script PATH
which isn't surprising.
The default PATH
for cron jobs is fairly limited.
With ipset
located in /usr/sbin
that is the path that must be added to the cron script's PATH
variable.
You talked about this in your question
I have seen others using a line such as PATH=/usr/bin:/bin:/usr/sbin:/sbin to resolve problems involving the script's location, but, I don't exactly know what this does.
What that does is set the PATH
variable to those paths (from whatever the default value was).
The PATH
variable contains the paths where the shell looks for binaries/scripts/etc. to run when you try to run them as commands.
Upvotes: 1