Community discussions

MikroTik App
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Scheduled script to clear proxy cache doesnt work

Mon Dec 28, 2009 7:43 pm

Hi all

I have several web proxy cache... with this scrpt:
/ip proxy set enable=no
:delay 10s
/ip proxy clear-cache
If I run this script in certains ways I obtain different results.

1. If I use the "scheduled" mode with the winbox open, then the proxy cache disk (sata in secondary disk) becomes to 0 Kb. This is ok.
2. If I run manually the script from winbox, then the proxy cache disk (sata in secondary disk) becomes to 0 Kb. This is ok.
3. If I want to use the scheduled function with the winbox closed, the script runs, BUT the cache disk NOT erase any data, and follows with her previous size.

I want to clear the cache disk for better performance after 7 days in automatic way, but in the scheduled mode the data over the disk follows after the scripts runs at the indicate date.

I revised the permissions and all looks ok... but in scheduled mode with the winbox closed, the sata disk NOT erase the data.

Any idea?
 
Fidoman
just joined
Posts: 3
Joined: Mon Dec 22, 2008 4:49 pm

Re: Scheduled script to clear proxy cache doesnt work

Tue Dec 29, 2009 12:37 am

Check if the "run count" of scheduler and of scripts changes.
And check the clock and the "next run" of scheduler.

Good luck
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Re: Scheduled script to clear proxy cache doesnt work

Tue Dec 29, 2009 2:57 pm

all this items has been checked.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Scheduled script to clear proxy cache doesnt work

Tue Dec 29, 2009 3:24 pm

and do they increase, have sane values?
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Re: Scheduled script to clear proxy cache doesnt work

Wed Dec 30, 2009 1:02 am

they increased all the time... the proxy follow runs at the scheduled time without problem... this has confirmed on log

but it has no visible effects after the script runs with in scheduled with the winbox closed. (if I run the script manually they clear the disk ok)

the complete script "ClearCache" is here
/ip proxy set enable=no
:delay 10s
/ip proxy clear-cache
:delay 15m
/ip proxy set enable=yes
the scheduler config:
 /system scheduler> pr
Flags: X - disabled 
 #   NAME   START-DATE  START-TIME   INTERVAL             ON-EVENT   RUN-COUNT 
0   Cle... dec/18/2009 14:41:00     1w                   ClearCache 1 
the proxy config:
/ip proxy> pr
                 enabled: yes
             src-address: 0.0.0.0
                    port: 3128
            parent-proxy: 0.0.0.0
       parent-proxy-port: 0
     cache-administrator: "webmaster"
          max-cache-size: unlimited
           cache-on-disk: yes
  max-client-connections: 1000
  max-server-connections: 1000
          max-fresh-time: 3d
   serialize-connections: no
       always-from-cache: no
          cache-hit-dscp: 4
             cache-drive: sata1
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Fri Jan 01, 2010 10:30 pm

What version are you running? One thing to check is permissions for the script. Post the output of:
/system scheduler export
You may want to trim that output to just show the specific script
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 1:31 am

/system scheduler
add comment="" disabled=no interval=1w name=ClearCache on-event=ClearCache \
    policy=reboot,read,write,policy,test,password,sniff,sensitive \
    start-date=jan/01/1970 start-time=05:15:00
Mikrotik V 4.2
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 2:55 am

Please add:
/system script export
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 2:58 am

Please add:
/system script export
Also, try running (from the CLI):
/system script run ClearCache
From your previous post, it seems that it runs when you do that. Is that correct?
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 3:08 am

One more thing to try. Run (CLI):
/system scheduler 
set ClearCache policy=ftp,local,password,policy,read,reboot,sensitive,sniff,ssh,telnet,test,web,winbox,write
/system script 
set ClearCache policy=ftp,local,password,policy,read,reboot,sensitive,sniff,ssh,telnet,test,web,winbox,write
That gives both the script and scheduler FULL policy rights. If that makes it work correctly, then you should be able to remove some of the rights one at a time to see which rights are minimum requirements. Note that there are several policy options available in CLI that are NOT configurable in Winbox. These include:
  • ftp
  • local
  • ssh
  • telnet
  • web
  • winbox
Just adjust the above policy configurations via the CLI until you get the right set of rights.
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 5:14 am

One more thing to try. Run (CLI):
/system scheduler 
set ClearCache policy=ftp,local,password,policy,read,reboot,sensitive,sniff,ssh,telnet,test,web,winbox,write
/system script 
set ClearCache policy=ftp,local,password,policy,read,reboot,sensitive,sniff,ssh,telnet,test,web,winbox,write
That gives both the script and scheduler FULL policy rights. If that makes it work correctly, then you should be able to remove some of the rights one at a time to see which rights are minimum requirements. Note that there are several policy options available in CLI that are NOT configurable in Winbox. These include:
  • ftp
  • local
  • ssh
  • telnet
  • web
  • winbox
Just adjust the above policy configurations via the CLI until you get the right set of rights.
Thank you Butch by your help.

This solution (set full policy rights) has not work. Same results.

This issue really seems a bug. I think.

The script ONLY works ok by run manually within winbox or in CLI. In scheduled run, ONLY works with the winbox session opened with MY EYES put on her. :shock:

BUT If I go sleep (or anything else :) ) in scheduled mode with the winbox session CLOSED it doesnt works at all and the size of data in SATA disk is equal to the size previous script run, and after all they follows increase as normal run of the proxy. :(
 
guille4
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 93
Joined: Tue Sep 29, 2009 9:23 pm

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 5:23 am


Also, try running (from the CLI):
/system script run ClearCache
From your previous post, it seems that it runs when you do that. Is that correct?
Here I found something !!

If I run "/system script run ClearCache" in the CLI I need to press "y" (yes) then the scripts REALLY clear the disk and GO to size 0.

See:
/system script run ClearCache
Clear all web proxy cache, yes? [y/N]: 
y
cache will be cleared shortly
Questions:

This can be the problem?

And if yes... How I can put the "y" into the script?

Thanks in advance.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 6:01 am

That would be the problem. As far as I know, there's no way to automatically answer prompts in scripts. Maybe put in a feature request that adds an optional parameter to the command to circumvent the prompt in scripts? Kinda like "/noconfirm" on interactive Cisco IOS commands.
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 7:10 am

If I run "/system script run ClearCache" in the CLI I need to press "y" (yes) then the scripts REALLY clear the disk and GO to size 0.

See:
/system script run ClearCache
Clear all web proxy cache, yes? [y/N]: 
y
cache will be cleared shortly
Questions:

This can be the problem?

And if yes... How I can put the "y" into the script?

Thanks in advance.
I am looking at another option
 
User avatar
butche
Trainer
Trainer
Posts: 428
Joined: Fri May 28, 2004 6:14 pm
Location: Missouri, USA
Contact:

Re: Scheduled script to clear proxy cache doesnt work

Sat Jan 02, 2010 7:37 am

I thought there may be another method to do this, but it is not possible. Every option I have tried will run into at least one prompt to confirm an action.

Who is online

Users browsing this forum: baragoon, Bing [Bot], Google [Bot], Guntis, sch and 91 guests