Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with cron job 1

Status
Not open for further replies.

openeratech

Technical User
May 23, 2005
62
IN


Hi All,

I have configured ACL on my squid proxy. Bascially i dont want users to use personal webmails or some other sites during business hours that would choke the bandwidth otherwise. So i have configured time based access for this sites.

This ACL what i have configured depends on one TXT file which has list of the websites that i dont have to have access. So i have created one more TXT file. So the script will first of all stop the squid service and then delete the original TXT file and then copy the other one and then start the squid service. This will happen two times a day which the CRON job takes care of.

But the actual problem what i am facing is, even though the script will do the job, the squid proxy doesnt take into account the new TXT file. Only if i login to the server and do a SERVICE SQUID RESTART then only it is accepting the TXT file. However in the script i have mentioned this command but somehow it doesnt take effect. I am clueless what actually is the problem.

Please guide.

Regards
Yunus
 
It's probably an environment problem. As a first step, try including the PATH which works interactively as an early statement in your cron script, eg

export PATH=/path/as/defined/interactively.

HTH.
 
hi,

I didnt got this one right. Actually i dont think it is a PATH problem because it does everything that is stated in the script.

Here is the script:

service squid stop
cd /etc/squid/acl
rm -rf banned.txt
cp /etc/squid/acl/allow/banned.txt /etc/squid/acl
service squid start


Regards
Yunus
 
Does cron mail you an error message? I'd still try adding the appropriate PATH first, to be honest.
 
No it doesnt mail me. Okay keeping your words how shall i export the entire PATH, since the PATH are too long for root. Is there any single command which will add all the path.

Interactively logging in gives the following path for root. Cron job is configured to run as root.

So what would be the command to add the following PATH:
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin

regards
Yunus
 
I don't quite understand your 'too long' remark, but putting this at the head of the script, will add the above path to whatever PATH already exists:

export PATH=$PATH:/bin:/sbin:/usr/bin:/...remainder of your path as above

Let us know if this works and if not, we can dig a little deeper.
 
when i give the above command i am getting "invalid identifier" error.

Shall i need to give something like this:

export PATH=${PATH}:/bin:/sbin:/usr/bin:

I mentioned long in the sense that there are lot of PATH which has to be defined to make it exactly same as interactive login.

I am unable to execute this in one singe command. Thats why i am asking your help for this.

Regards
Yunus
 
... it does everything that is stated in the script."

Your script contains "service squid stop" without providing the path to "service". Either "/sbin/service squid stop" or "/etc/init.d/squid stop" should work.

Also, as I recall, there is an option for Squid to reload its configuration without restarting, something like "/etc/init.d/squid reload". Try running the Squid startup script without options to see.
 
hi,

Adding path has solved the problem. In that way even lgarner's solution would have worked.

Thanks for your efforts in solving the problem.

Cheers
Yunus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top