Wifi schedule After reboot system

Hello,

I have the "WiFi schedule" installed on my router.
It's working well.
Therefore, when I turn OFF and ON m'y router the WiFi is always ON even if the time is on the OFF period.
Do you have any Idea on the way to solve this?

Regards.

I don't know if this will work (and if it does it might not be the best way), but it wouldn't harm to try:

Add /etc/config/wifi_schedule/wifi_schedule.sh recheck to rc.local.

I will try as soon as possible.
I will inform you...
Regards.

Hello,

I'm sorry but how can I add "*/etc/config/wifi_schedule/wifi_schedule.sh recheck to `rc.local*".
I use WinSCP to see all directories:

Regards.

Edit the file /etc/rc.local and add the line /etc/config/wifi_schedule/wifi_schedule.sh recheck to it.

Before:

root@wap:~# cat /etc/rc.local
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

exit 0

After:

root@wap:~# cat /etc/rc.local
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

/etc/config/wifi_schedule/wifi_schedule.sh recheck
exit 0

You just double-click the file in WinSCP and it will open in your default text editor. Edit it, save and close and it will write it back to the router.

  • Now my file "rc.local" is like this:
    Local%20-%20WinSCP

  • But it seems that there is no file "/etc/config/wifi_schedule/wifi_schedule.sh":

  • I can find 2 files with this name here :
    sh

What can I do please?

It shouldn't make a difference, but try the path of the first one (the one in overlay folder).

Make sure that your rc.local file enfs with exit 0 as shown in @iplaywithtoys post.

Is there any difference between "wifi_schedule" and "wifi_schedule.sh"?
My "wifi_schedule" file:
wifi_schedule

opkg update
opkg install diffutils
diff /etc/config/wifi_schedule /usr/bin/wifi_schedule.sh

Here is the answer of the command "diff /etc/config/wifi_schedule /usr/bin/wifi_schedule.sh":

login as: root
root@192.168.1.1's password:


BusyBox v1.28.4 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 18.06.4, r7808-ef686b7292
 -----------------------------------------------------
root@OpenWrt_Salon:~#
root@OpenWrt_Salon:~# diff /etc/config/wifi_schedule /usr/bin/wifi_schedule.sh
0a1
#!/bin/sh
2,14c3,15
< config global
<       option recheck_interval '10'
<       option modules_retries '10'
<       option logging '1'
<       option unload_modules '0'
<       option enabled '1'
<
< config entry 'Test_01'
<       option daysofweek 'Monday Tuesday Wednesday Thursday Friday Saturday Sun                                                                                                                                                             day'
<       option starttime '08:00'
<       option stoptime '10:00'
<       option forcewifidown '1'
<       option enabled '1'
---
# Copyright (c) 2016, prpl Foundation
#
# Permission to use, copy, modify, and/or distribute this software for any pur                                                                                                                                                             pose with or without
# fee is hereby granted, provided that the above copyright notice and this per                                                                                                                                                             mission notice appear
# in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WIT                                                                                                                                                             H REGARD TO THIS SOFTWARE
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT                                                                                                                                                              SHALL THE AUTHOR BE LIABLE
# FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES W                                                                                                                                                             HATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE O                                                                                                                                                             R OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE                                                                                                                                                             .
#
# Author: Nils Koenig <openwrt@newk.it>
15a17,321
SCRIPT=$0
LOCKFILE=/tmp/wifi_schedule.lock
LOGFILE=/tmp/log/wifi_schedule.log
LOGGING=0 #default is off
PACKAGE=wifi_schedule
GLOBAL=${PACKAGE}.@global[0]
>
_log()
{
    if [ ${LOGGING} -eq 1 ]; then
        local ts=$(date)
        echo "$ts $@" >> ${LOGFILE}
    fi
}
>
_exit()
{
    local rc=$1
    lock -u ${LOCKFILE}
    exit ${rc}
}
>
_cron_restart()
{
    /etc/init.d/cron restart > /dev/null
}
>
_add_cron_script()
{
    (crontab -l ; echo "$1") | sort | uniq | crontab -
    _cron_restart
}
>
_rm_cron_script()
{
    crontab -l | grep -v "$1" |  sort | uniq | crontab -
    _cron_restart
}
>
_get_uci_value_raw()
{
    local value
    value=$(uci get $1 2> /dev/null)
    local rc=$?
    echo ${value}
    return ${rc}
}
>
_get_uci_value()
{
    local value
    value=$(_get_uci_value_raw $1)
    local rc=$?
    if [ ${rc} -ne 0 ]; then
        _log "Could not determine UCI value $1"
        return 1
    fi
    echo ${value}
}
>
_format_dow_list()
{
    local dow=$1
    local flist=""
    local day
    for day in ${dow}
    do
        if [ ! -z ${flist} ]; then
            flist="${flist},"
        fi
        flist="${flist}${day:0:3}"
    done
    echo ${flist}
}
>
>
_enable_wifi_schedule()
{
    local entry=$1
    local starttime
    local stoptime
    starttime=$(_get_uci_value ${PACKAGE}.${entry}.starttime) || _exit 1
    stoptime=$(_get_uci_value ${PACKAGE}.${entry}.stoptime) || _exit 1
>
    local dow
    dow=$(_get_uci_value_raw ${PACKAGE}.${entry}.daysofweek) || _exit 1
>
    local fdow=$(_format_dow_list "$dow")
    local forcewifidown
    forcewifidown=$(_get_uci_value ${PACKAGE}.${entry}.forcewifidown)
    local stopmode="stop"
    if [ $forcewifidown -eq 1 ]; then
        stopmode="forcestop"
    fi
>
>
    local stop_cron_entry="$(echo ${stoptime} | awk -F':' '{print $2, $1}') *                                                                                                                                                              * ${fdow} ${SCRIPT} ${stopmode}" # ${entry}"
    _add_cron_script "${stop_cron_entry}"
>
    if [[ $starttime != $stoptime ]]
    then
        local start_cron_entry="$(echo ${starttime} | awk -F':' '{print $2, $1                                                                                                                                                             }') * * ${fdow} ${SCRIPT} start" # ${entry}"
        _add_cron_script "${start_cron_entry}"
    fi
>
    return 0
}
>
_get_wireless_interfaces()
{
    local n=$(cat /proc/net/wireless | wc -l)
    cat /proc/net/wireless | tail -n $(($n - 2))|awk -F':' '{print $1}'| sed                                                                                                                                                               's/ //'
}
>
>
get_module_list()
{
    local mod_list
    local _if
    for _if in $(_get_wireless_interfaces)
    do
        local mod=$(basename $(readlink -f /sys/class/net/${_if}/device/driver                                                                                                                                                             ))
        local mod_dep=$(modinfo ${mod} | awk '{if ($1 ~ /depends/) print $2}')
        mod_list=$(echo -e "${mod_list}\n${mod},${mod_dep}" | sort | uniq)
    done
    echo $mod_list | tr ',' ' '
}
>
save_module_list_uci()
{
    local list=$(get_module_list)
    uci set ${GLOBAL}.modules="${list}"
    uci commit ${PACKAGE}
}
>
_unload_modules()
{
    local list=$(_get_uci_value ${GLOBAL}.modules)
    local retries
    retries=$(_get_uci_value ${GLOBAL}.modules_retries) || _exit 1
    _log "unload_modules ${list} (retries: ${retries})"
    local i=0
    while [[ ${i} -lt ${retries}  &&  "${list}" != "" ]]
    do
        i=$(($i+1))
        local mod
        local first=0
        for mod in ${list}
        do
            if [ $first -eq 0 ]; then
                list=""
                first=1
            fi
            rmmod ${mod} > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                list="$list $mod"
            fi
        done
    done
}
>
>
_load_modules()
{
    local list=$(_get_uci_value ${GLOBAL}.modules)
    local retries
    retries=$(_get_uci_value ${GLOBAL}.modules_retries) || _exit 1
    _log "load_modules ${list} (retries: ${retries})"
    local i=0
    while [[ ${i} -lt ${retries}  &&  "${list}" != "" ]]
    do
        i=$(($i+1))
        local mod
        local first=0
        for mod in ${list}
        do
            if [ $first -eq 0 ]; then
                list=""
                first=1
            fi
            modprobe ${mod} > /dev/null 2>&1
            rc=$?
            if [ $rc -ne 255 ]; then
                list="$list $mod"
            fi
        done
    done
}
>
_create_cron_entries()
{
    local entries=$(uci show ${PACKAGE} 2> /dev/null | awk -F'.' '{print $2}'                                                                                                                                                              | grep -v '=' | grep -v '@global\[0\]' | uniq | sort)
    local _entry
    for entry in ${entries}
    do
        local status
        status=$(_get_uci_value ${PACKAGE}.${entry}.enabled) || _exit 1
        if [ ${status} -eq 1 ]
        then
            _enable_wifi_schedule ${entry}
        fi
    done
}
>
check_cron_status()
{
    local global_enabled
    global_enabled=$(_get_uci_value ${GLOBAL}.enabled) || _exit 1
    _rm_cron_script "${SCRIPT}"
    if [ ${global_enabled} -eq 1 ]; then
        _create_cron_entries
    fi
}
>
disable_wifi()
{
    _rm_cron_script "${SCRIPT} recheck"
    /sbin/wifi down
    local unload_modules
    unload_modules=$(_get_uci_value_raw ${GLOBAL}.unload_modules) || _exit 1
    if [[ "${unload_modules}" == "1" ]]; then
        _unload_modules
    fi
}
>
soft_disable_wifi()
{
    local _disable_wifi=1
    local iwinfo=/usr/bin/iwinfo
    if [ ! -e ${iwinfo} ]; then
        _log "${iwinfo} not available, skipping"
        return 1
    fi
>
    # check if no stations are associated
    local _if
    for _if in $(_get_wireless_interfaces)
    do
        output=$(${iwinfo} ${_if} assoclist)
        if [[ "$output" != "No station connected" ]]
        then
            _disable_wifi=0
            local stations=$(echo ${output}| grep -o -E '([[:xdigit:]]{1,2}:){                                                                                                                                                             5}[[:xdigit:]]{1,2}' | tr '\n' ' ')
            _log "Station(s) ${stations}associated on ${_if}"
        fi
    done
>
    if [ ${_disable_wifi} -eq 1 ]; then
        _log "No stations associated, disable wifi."
        disable_wifi
    else
        _log "Could not disable wifi due to associated stations, retrying..."
        local recheck_interval=$(_get_uci_value ${GLOBAL}.recheck_interval)
        _add_cron_script "*/${recheck_interval} * * * * ${SCRIPT} recheck"
    fi
}
>
enable_wifi()
{
    _rm_cron_script "${SCRIPT} recheck"
    local unload_modules
    unload_modules=$(_get_uci_value_raw ${GLOBAL}.unload_modules) || _exit 1
    if [[ "${unload_modules}" == "1" ]]; then
        _load_modules
    fi
    /sbin/wifi
}
>
usage()
{
    echo ""
    echo "$0 cron|start|stop|forcestop|recheck|getmodules|savemodules|help"
    echo ""
    echo "    UCI Config File: /etc/config/${PACKAGE}"
    echo ""
    echo "    cron: Create cronjob entries."
    echo "    start: Start wifi."
    echo "    stop: Stop wifi gracefully, i.e. check if there are stations ass                                                                                                                                                             ociated and if so keep retrying."
    echo "    forcestop: Stop wifi immediately."
    echo "    recheck: Recheck if wifi can be disabled now."
    echo "    getmodules: Returns a list of modules used by the wireless drive                                                                                                                                                             r(s)"
    echo "    savemodules: Saves a list of automatic determined modules to UCI                                                                                                                                                             "
    echo "    help: This description."
    echo ""
}
>
##############################################################################                                                                                                                                                             #
# MAIN
##############################################################################                                                                                                                                                             #
LOGGING=$(_get_uci_value ${GLOBAL}.logging) || _exit 1
_log ${SCRIPT} $1 $2
lock ${LOCKFILE}
>
case "$1" in
    cron) check_cron_status ;;
    start) enable_wifi ;;
    forcestop) disable_wifi ;;
    stop) soft_disable_wifi ;;
    recheck) soft_disable_wifi ;;
    getmodules) get_module_list ;;
    savemodules) save_module_list_uci ;;
    help|--help|-h|*) usage ;;
esac
>
_exit 0
root@OpenWrt_Salon:~#

Do you understand anything to this?

The recheck function on the "rc.local" file is supposed to recheck what kind of file.
This one :

config global
	option recheck_interval '10'
	option modules_retries '10'
	option logging '1'
	option unload_modules '0'
	option enabled '1'

config entry 'Test_01'
	option daysofweek 'Monday Tuesday Wednesday Thursday Friday Saturday Sunday'
	option starttime '08:00'
	option stoptime '10:00'
	option forcewifidown '1'
	option enabled '1'

**Or this one** : 
 #!/bin/sh

# Copyright (c) 2016, prpl Foundation
#
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without
# fee is hereby granted, provided that the above copyright notice and this permission notice appear
# in all copies.
# 
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
# FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Nils Koenig <openwrt@newk.it>

SCRIPT=$0
LOCKFILE=/tmp/wifi_schedule.lock
LOGFILE=/tmp/log/wifi_schedule.log
LOGGING=0 #default is off
PACKAGE=wifi_schedule
GLOBAL=${PACKAGE}.@global[0]

_log()
{
    if [ ${LOGGING} -eq 1 ]; then
        local ts=$(date)
        echo "$ts $@" >> ${LOGFILE}
    fi
}

_exit()
{
    local rc=$1
    lock -u ${LOCKFILE}
    exit ${rc}
}

_cron_restart()
{
    /etc/init.d/cron restart > /dev/null
}

_add_cron_script()
{
    (crontab -l ; echo "$1") | sort | uniq | crontab -
    _cron_restart
}

_rm_cron_script()
{
    crontab -l | grep -v "$1" |  sort | uniq | crontab -
    _cron_restart
}

_get_uci_value_raw()
{
    local value
    value=$(uci get $1 2> /dev/null)
    local rc=$?
    echo ${value}
    return ${rc}
}

_get_uci_value()
{
    local value
    value=$(_get_uci_value_raw $1)
    local rc=$?
    if [ ${rc} -ne 0 ]; then
        _log "Could not determine UCI value $1"
        return 1
    fi
    echo ${value}
}

_format_dow_list()
{
    local dow=$1
    local flist=""
    local day
    for day in ${dow}
    do
        if [ ! -z ${flist} ]; then
            flist="${flist},"
        fi
        flist="${flist}${day:0:3}"
    done
    echo ${flist}
}


_enable_wifi_schedule()
{
    local entry=$1
    local starttime
    local stoptime
    starttime=$(_get_uci_value ${PACKAGE}.${entry}.starttime) || _exit 1
    stoptime=$(_get_uci_value ${PACKAGE}.${entry}.stoptime) || _exit 1

    local dow
    dow=$(_get_uci_value_raw ${PACKAGE}.${entry}.daysofweek) || _exit 1 
    
    local fdow=$(_format_dow_list "$dow")
    local forcewifidown
    forcewifidown=$(_get_uci_value ${PACKAGE}.${entry}.forcewifidown)
    local stopmode="stop"
    if [ $forcewifidown -eq 1 ]; then
        stopmode="forcestop"
    fi


    local stop_cron_entry="$(echo ${stoptime} | awk -F':' '{print $2, $1}') * * ${fdow} ${SCRIPT} ${stopmode}" # ${entry}"
    _add_cron_script "${stop_cron_entry}"

    if [[ $starttime != $stoptime ]]                             
    then                                                         
        local start_cron_entry="$(echo ${starttime} | awk -F':' '{print $2, $1}') * * ${fdow} ${SCRIPT} start" # ${entry}"
        _add_cron_script "${start_cron_entry}"
    fi

    return 0
}

_get_wireless_interfaces()
{
    local n=$(cat /proc/net/wireless | wc -l)
    cat /proc/net/wireless | tail -n $(($n - 2))|awk -F':' '{print $1}'| sed  's/ //' 
}


get_module_list()
{
    local mod_list
    local _if
    for _if in $(_get_wireless_interfaces)
    do
        local mod=$(basename $(readlink -f /sys/class/net/${_if}/device/driver))
        local mod_dep=$(modinfo ${mod} | awk '{if ($1 ~ /depends/) print $2}')
        mod_list=$(echo -e "${mod_list}\n${mod},${mod_dep}" | sort | uniq)
    done
    echo $mod_list | tr ',' ' '
}

save_module_list_uci()
{
    local list=$(get_module_list)
    uci set ${GLOBAL}.modules="${list}"
    uci commit ${PACKAGE}
}

_unload_modules()
{
    local list=$(_get_uci_value ${GLOBAL}.modules) 
    local retries
    retries=$(_get_uci_value ${GLOBAL}.modules_retries) || _exit 1
    _log "unload_modules ${list} (retries: ${retries})"
    local i=0
    while [[ ${i} -lt ${retries}  &&  "${list}" != "" ]]
    do  
        i=$(($i+1))
        local mod
        local first=0
        for mod in ${list}
        do
            if [ $first -eq 0 ]; then
                list=""
                first=1
            fi
            rmmod ${mod} > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                list="$list $mod"
            fi
        done
    done
}


_load_modules()
{
    local list=$(_get_uci_value ${GLOBAL}.modules)
    local retries
    retries=$(_get_uci_value ${GLOBAL}.modules_retries) || _exit 1
    _log "load_modules ${list} (retries: ${retries})"
    local i=0
    while [[ ${i} -lt ${retries}  &&  "${list}" != "" ]]
    do  
        i=$(($i+1))
        local mod
        local first=0
        for mod in ${list}
        do
            if [ $first -eq 0 ]; then
                list=""
                first=1
            fi
            modprobe ${mod} > /dev/null 2>&1
            rc=$? 
            if [ $rc -ne 255 ]; then
                list="$list $mod"
            fi
        done
    done
}

_create_cron_entries()
{
    local entries=$(uci show ${PACKAGE} 2> /dev/null | awk -F'.' '{print $2}' | grep -v '=' | grep -v '@global\[0\]' | uniq | sort)
    local _entry
    for entry in ${entries}
    do 
        local status
        status=$(_get_uci_value ${PACKAGE}.${entry}.enabled) || _exit 1
        if [ ${status} -eq 1 ]
        then
            _enable_wifi_schedule ${entry}
        fi
    done
}

check_cron_status()
{
    local global_enabled
    global_enabled=$(_get_uci_value ${GLOBAL}.enabled) || _exit 1
    _rm_cron_script "${SCRIPT}"
    if [ ${global_enabled} -eq 1 ]; then
        _create_cron_entries
    fi
}

disable_wifi()
{
    _rm_cron_script "${SCRIPT} recheck"
    /sbin/wifi down
    local unload_modules
    unload_modules=$(_get_uci_value_raw ${GLOBAL}.unload_modules) || _exit 1
    if [[ "${unload_modules}" == "1" ]]; then
        _unload_modules
    fi    
}

soft_disable_wifi()
{
    local _disable_wifi=1
    local iwinfo=/usr/bin/iwinfo
    if [ ! -e ${iwinfo} ]; then
        _log "${iwinfo} not available, skipping"
        return 1
    fi

    # check if no stations are associated
    local _if
    for _if in $(_get_wireless_interfaces)
    do
        output=$(${iwinfo} ${_if} assoclist)
        if [[ "$output" != "No station connected" ]]
        then
            _disable_wifi=0
            local stations=$(echo ${output}| grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tr '\n' ' ')
            _log "Station(s) ${stations}associated on ${_if}"
        fi
    done

    if [ ${_disable_wifi} -eq 1 ]; then
        _log "No stations associated, disable wifi."
        disable_wifi
    else
        _log "Could not disable wifi due to associated stations, retrying..."
        local recheck_interval=$(_get_uci_value ${GLOBAL}.recheck_interval)
        _add_cron_script "*/${recheck_interval} * * * * ${SCRIPT} recheck"
    fi
}

enable_wifi()
{
    _rm_cron_script "${SCRIPT} recheck"
    local unload_modules
    unload_modules=$(_get_uci_value_raw ${GLOBAL}.unload_modules) || _exit 1
    if [[ "${unload_modules}" == "1" ]]; then
        _load_modules
    fi
    /sbin/wifi
}

usage()
{
    echo ""
    echo "$0 cron|start|stop|forcestop|recheck|getmodules|savemodules|help"
    echo ""
    echo "    UCI Config File: /etc/config/${PACKAGE}"
    echo ""
    echo "    cron: Create cronjob entries."
    echo "    start: Start wifi."
    echo "    stop: Stop wifi gracefully, i.e. check if there are stations associated and if so keep retrying."
    echo "    forcestop: Stop wifi immediately."
    echo "    recheck: Recheck if wifi can be disabled now."
    echo "    getmodules: Returns a list of modules used by the wireless driver(s)"
    echo "    savemodules: Saves a list of automatic determined modules to UCI"
    echo "    help: This description."
    echo ""
}

###############################################################################
# MAIN
###############################################################################
LOGGING=$(_get_uci_value ${GLOBAL}.logging) || _exit 1
_log ${SCRIPT} $1 $2
lock ${LOCKFILE}

case "$1" in
    cron) check_cron_status ;;
    start) enable_wifi ;;
    forcestop) disable_wifi ;;
    stop) soft_disable_wifi ;;
    recheck) soft_disable_wifi ;;
    getmodules) get_module_list ;;
    savemodules) save_module_list_uci ;;
    help|--help|-h|*) usage ;;
esac

_exit 0

I am guessing that as it is a cron job, you’d need to check what time it is after you get NTP sync, then set the wireless state. The cron job only “fires” when the times are crossed.

Hello,
I'm not very clever with OpenWRT language. I don't really understand what you are trying to explain to me.
What kind of test can I do?

Please use the Pre-formatted text tool </> not the quote tool for including code.

It was the .sh file I am talking about.

@jeff says he thinks it's a timer thing that's invoked when time comes. So if you turn on the router during the wifi off times, they started on by default and the timer doesn't do anything about them, because it's only invoked at the exact hours you set them to.

Anyway, see if the line I sent earlier will "make it realise" that WiFi is supposed to be off then that's the easy solution. If not then we'll have to figure something out.

1 Like

I've modify the "rc.local" like this:

etc/config/wifi_schedule recheck
overlay/upper/etc/config/wifi_schedule recheck
overlay/upper/usr/bin/wifi_schedule.sh recheck
usr/bin/wifi_schedule.sh recheck
exit 0

It seems to work but I don't know wich file make the job.
Do you have an idea?

Thank you mhegab!

Easy enough to test. Try each line, one at a time. When you identify which one works, stick with it.

My best advise would be to remove the first 3 lines and try

etc/config/wifi_schedule is a data file, not an executable, so that line won't accomplish anything.

In general, there is no reason to access files on /rom/ or /overlay/ -- those two combine to become your root file system, which is almost always what you want to access.

/usr/bin/wifi_schedule.sh recheck

(note the leading slash) is what "does something" for you.

While OK in /etc/rc.local, it is possible that NTP doesn't set the time prior to that script running. It's OK to leave it there, but I'd use a hotplug script -- https://openwrt.org/docs/guide-user/base-system/hotplug -- in /etc/hotplug.d/ntp/

1 Like

Finally it doesn't woks. The wifi was OFF because there was an error, not because it was on the OFF period of the wifi_schedule:

Sun Jul 28 19:38:14 CEST 2019 overlay/upper/usr/bin/wifi_schedule.sh recheck
Sun Jul 28 19:38:15 CEST 2019 No stations associated, disable wifi.
Sun Jul 28 19:38:17 CEST 2019 usr/bin/wifi_schedule.sh recheck
Sun Jul 28 19:38:18 CEST 2019 No stations associated, disable wifi.

I'm so disappointed!