Jump to content

Batch to Empty cache Files CRON JOb


natasha_thomas

Recommended Posts

Folks,

 

I am Caching the Content of each site in a Folder Called "textcache" which is there in Each Site. Each of my site has a PHP Script, which if Fired will empty all the content of this FOlder (textcache).

 

Script URL looks like: www.mydomain.com/icache/delcache.php

 

What i want is, I want ot CRON/Schedule calling this PHP So, i can frequently empty the cached files.

 

I want to Calling this Script Once a day.

 

 

I haev 10 Domains under one Cpanel, this script and Cache foldsrs are there on Each of the Site. Script URL is:

 

http:/www.domain1.com/icache/delcache.php

http:/www.domain2.com/icache/delcache.php

http:/www.domain3.com/icache/delcache.php

.

.

.

http:/www.domain10.com/icache/delcache.php

 

Will the below Batch File do this Job:

 

 

 

#!/bin/sh 

for i in `cat /list/of/domains`; do 
/usr/bin/curl --silent http://"$i"/icache/delcache.php 
done 

http:/www.domain1.com
http:/www.domain2.com
http:/www.domain3.com
http:/www.domain4.com
http:/www.domain5.com
http:/www.domain6.com
http:/www.domain7.com
http:/www.domain8.com
http:/www.domain9.com
http:/www.domain10.com

 

 

 

Could you Pleas help me Correcting this Batch File?

 

&

 

Where do i need to Put this Batch File on my Direcotry Structure?

 

 

Cheers

Natasha T

Link to comment
https://forums.phpfreaks.com/topic/223943-batch-to-empty-cache-files-cron-job/
Share on other sites

You shouldn't be executing these scripts via a url request. In fact I wouldn't even be using php.

 

A simple bash one liner executed directly from within your crontab would suffice.

 

0 0 * * *  rm -fr /path/to/sites/*/icache/*

 

Thanks Thrope.

 

But, as i understand, if i go by this Solution, then i will have to Manually setup Cron Job for Each and every Website of mine on my VPS... Right?

 

If so, i rather want a batch File  in which i can specify the Domain names and it runs for all those domain names.

 

Natasha

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.