1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Echo

Discussion in 'Tomato Firmware' started by lhahehal, Dec 4, 2007.

  1. lhahehal

    lhahehal Network Guru Member

    Echo 15 means 15 seconds its issue the command ?? then echo 10 would be 10 sec ??

    would doing echo dropidle everything 10sec be harsh on the router ?
     
  2. PeterT

    PeterT Network Guru Member

    I presume you are referring to your earlier post
    As was said in reply to your earlier post, all this is doing is at the time that either the init or wan-up script runs, is to perform the drop idle function as found in Advanced / Conntrack / Netfilter button.

    It is NOT saying to perform that on a regular schedule, just that one time.

    Also, all the echo command is doing here is copying the value "15" to the "file" /proc/net/expire_early.
     
  3. lhahehal

    lhahehal Network Guru Member

    i see.. so is there a way to let it perform on a regular schedule ?
     
  4. PeterT

    PeterT Network Guru Member

    Try this...

    Set this script up in either the INIT or WANUP script. Using WANUP is easier in that you don;t have to reset the router to load it the first time.

    Code:
    logger WANUP: Script Executing
    sleep 5
    
    if [ ! -x /tmp/drop_con.sh ] ; then 
      logger Creating script
      cat > /tmp/drop_con.sh <<EOF
    #!/bin/sh
    logger Expire_Early: Executing Expire_Early
    echo 15 > /proc/net/expire_early
    EOF
      chmod +x /tmp/drop_con.sh
    fi 
    
    logger WANUP: Scheduling Expire Early
    cru a drop_con "0,15,30,45 * * * * /tmp/drop_con.sh"
    
    logger WANUP: Script terminating
    
    You will probably want to adjust the schedule found in the cru command line

    Syntax for cru is add: cru a <unique id> <"min hour day month week command">

    My example runs this every 15 minutes; changing the
    Code:
    "0,15,30,45 * * * * /tmp/drop_con.sh"
    
    to
    Code:
    "0 0,2,4,8,10,12,14,16,18,20,22 * * *  /tmp/drop_con.sh"
    
    would clean the connections every 2 hours.

    Just remember you need to have 6 fields, and an * means ANY.

    Whatever you do DON'T use an * in the first field; this would run your script every minute :)
     
  5. lhahehal

    lhahehal Network Guru Member

    Code:
    cru a drop_con "15 0 * * * /tmp/drop_con.sh"
    
    after reading the faq, i was wondering how come the faq stated that short command would do the trick ?
    is it cause there is no drop_con.sh ?? btw where do we know the <unique id> ?
     
  6. PeterT

    PeterT Network Guru Member

    The unique ID in the CRU is what YOU want to use.

    If you access the router via ssh and type "cru l" you will see all the existing scheduled cron entries.

    The drop_con.sh script is created in the first part of the script I gave you.

    Not sure what you mean by
    Remember, all that echo 15 > /proc/net/expire_early does is to perform the clearing of the connections ONCE. All my script IS doing is to create a script and then schedule it to run via cru at a regular interval.
     
  7. lhahehal

    lhahehal Network Guru Member

    okay i understand .. just to clarify the drop_con.sh is to drop ideal connections right ??

    if it is wouldnt the script be easier with

    for 15 mins
    Code:
    cru a drop_con "15 0 * * * /tmp/drop_con.sh"
     
  8. PeterT

    PeterT Network Guru Member

    As I said.. it's up to you as to how often you want to drop idle connections. The "15 0 * * *" that you list will drop idle connections once a day at 15 minutes past midnight.

    If that's the schedule you want; use it...

    If you want once an hour use "15 * * * *" which will ruin the script at 15 minutes past every hour.
     
  9. lhahehal

    lhahehal Network Guru Member

    Code:
    logger WANUP: Script Executing
    sleep 5
    
    if [ ! -x /tmp/drop_con.sh ] ; then 
      logger Creating script
      cat > /tmp/drop_con.sh <<EOF
    #!/bin/sh
    logger Expire_Early: Executing Expire_Early
    echo 15 > /proc/net/expire_early
    EOF
      chmod +x /tmp/drop_con.sh
    fi 
    
    logger WANUP: Scheduling Expire Early
    
    erm sorry think i let you mis understood, what i trying to ask was if by chance the cru command alone can drop the ideal connections then what about the long script above ? is that script assisting the drop connections cru ??
     
  10. PeterT

    PeterT Network Guru Member

    That "long" script is creating the short script I called "drop_con.sh" and then schediuling it to run when you want.

    Remember, the router does NOT have a hard-diskl the only "permament" storage it has is the so called "NVRAM".

    By storing this "big" script in one of the Router's startup scripts, this "big" script will
    a) get stored in NVRAM
    b) get executed by the router at the correct time (Startup or WANUP)
    c) create the drop_con.sh script if it does NOT already exist
    d) schedule the drop_con.sh script to run
     
  11. lhahehal

    lhahehal Network Guru Member

    ohh i see..thanks for all the help and explainations.. just another question..

    dont we have to state 0,15,30,45,60 ?? for the 15 mins drops ?? or router reads 60 min marker as 0 ?
     
  12. PeterT

    PeterT Network Guru Member

    The minutes go from 0 to 59 ...
     

Share This Page