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

Is an endlessly looping script OK to run?

Discussion in 'Tomato Firmware' started by adoucette, Apr 13, 2009.

  1. adoucette

    adoucette Addicted to LI Member

    [newb here]
    I have a script that loops and doesn't exit. I've put it in the "firewall" tab of the "scripts" section in the Tomato 1.23 GUI.
    Is this OK? Will Tomato know to load and run the script and continue additionally doing other stuff or will it get "stuck" on this loop? :confused:
    Will it cause problems? (so far I don't see any) If yes, how can I go about this differently to fix them?
    I'll paste the script below.

    Thanks for any info,

    #MAC address of Vista Media Center System
    #IP address of VMC system
    #IP address of DMA2x00 Media Center Extender
    #IP broadcast address - typically ends in 255
    while sleep 5
     /usr/bin/arping -c 1 -w 1 -I br0 $IP_DMA1
     if [ $ping_sts -eq 0 ] ; then
      #check if the VMC is running
      /usr/bin/arping -c 1 -w 1 -I br0 $IP_VMC
      if [ $ping_sts3 -ne 0 ] ; then
       #VMC is not running send WOL
       ether-wake -b $MAC_VMC
       sleep 1
      sleep 10
  2. mraneri

    mraneri LI Guru Member

    Not 100% sure, but I would avoid it. You can echo the script to a .txt file, chmod 777 on it (make it executable) and put it in a cron to run every few minutes. Do you need it to run every 5/15 seconds?
  3. adoucette

    adoucette Addicted to LI Member

    It does need to run every 5/15 seconds. Can cron do that?
    If yes, how do I set that up?
  4. mraneri

    mraneri LI Guru Member

    I don't know how to get cron to run more frequent than 1 minute...
  5. ntest7

    ntest7 Network Guru Member

    Yes, this is how to run a script in *nix. Cron isn't suitable for this as it can run a script at most once a minute.

    One minor change, change the last "done" to
    done >/dev/null &

    to throw away output and put the script in the background. Other than that, it's fine.
  6. adoucette

    adoucette Addicted to LI Member

    Great. I'll try that. Thanks.

Share This Page