natasha_thomas Posted January 10, 2011 Share Posted January 10, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/223943-batch-to-empty-cache-files-cron-job/ Share on other sites More sharing options...
trq Posted January 10, 2011 Share Posted January 10, 2011 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/* Quote Link to comment https://forums.phpfreaks.com/topic/223943-batch-to-empty-cache-files-cron-job/#findComment-1157305 Share on other sites More sharing options...
natasha_thomas Posted January 10, 2011 Author Share Posted January 10, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/223943-batch-to-empty-cache-files-cron-job/#findComment-1157327 Share on other sites More sharing options...
trq Posted January 10, 2011 Share Posted January 10, 2011 The wildcard after sites/ means that this script will remove all content from /path/to/sites/<siteA>/icache/, /path/to/sites/<siteB>/icache/, /path/to/sites/<siteC>/icache/ etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/223943-batch-to-empty-cache-files-cron-job/#findComment-1157340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.