How i make this script execute every minute without cron?

5,084

You are right that there are no goto commands but there are control loops with all the standard features. In your case, you just want to loop indefinitely:

while sleep 1m
do
    your commands here
    ....
done
Share:
5,084

Related videos on Youtube

sergius
Author by

sergius

Updated on September 18, 2022

Comments

  • sergius
    sergius over 1 year

    I have this:

    #!/bin/bash
    
    wlan=`/sbin/ifconfig wlan0 | grep inet\ addr | wc -l`
    if [ $wlan -eq 0 ]; then
    echo wlan0 not connected, connecting...
    echo
    sudo ifup wlan0
    logger wlan0 reconnected.
    echo
    echo wlan0 reconnected.
    else
    echo
    echo wlan0 connected. Nothing to do.
    fi    
    

    Maybe with sleep command i can make this wait a minute, but i've been reading that there is no "goto" command in shell scripting so i don't know how to jump from the end to the start of scripts so it can repeat the steps forever..