Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

How to run an admin task as a scheduled task on Windows [SUSSED]


Reply


3 Posts   411 Views

Avatar
simples

Community Member, 77 Posts

7 August 2013 at 8:40pm

Does anyone know how I could run

dev/buildcache?flush=1&force

each night on a PC which is running Windows 2003?

Thanks.

Avatar
simples

Community Member, 77 Posts

8 August 2013 at 7:56am

I did not expect this to be so challenging!

The following command

d:/wamp/bin/php/php5.2.11/php d:/vhosts/buckfastleigh/sapphire/cli-script.php dev/buildcache flush=1 force=1

which I have issued at a dos prompt has so far taken 6 hours to publish 14 out of 17 pages. This operation takes seconds when issued in the browser after logging in.

Rather than trying to jump though all the hoops which running cli-script.php involves I think my preferred option would now be to run the command from my browser by bypassing authentication through checking IP address and script name.

However even this appears to be difficult in so far as I am struggling to find in which script I can add logic to stop the login page from appearing.

I will probably get there in the end but why does this have to be so time consuming? So far I have spent all day on this.

Avatar
simples

Community Member, 77 Posts

9 August 2013 at 4:26am

Edited: 09/08/2013 6:23am

Ok, after 2 whole days of trying various things I think I have this sussed.

I inserted the following line at the top of Security::permissionFailure

if(stristr($_SERVER['QUERY_STRING'],'buildcache') && $_SERVER['REMOTE_ADDR']==$exempt_ip)return;

where $exempt_ip is the IP address which runs the script.

I am running Version 2.4.7.

PS. For some reason the script would only complete and create the cache files if the script's url contained a trailing slash.

e.g. dev/buildcache/?flush=1&force