
___x_cmd_sleep_beacon(){
    [ $# -gt 0 ]    ||  set -- 5

    case "$1" in
        -h|--help)      ___x_cmd help -m sleep beacon "$@" ; return 0 ;;
    esac

    local t="${1:-5}"  # 5 seconds to check it out ...

    local x_=5
    ___x_cmd humantime tosec_ "$t" || return $?

    sleep:info "Sleep in seconds: $x_"

    # Using ctrl-c to cancel ...
    while true; do
        ___x_cmd_cmds_sleep "$x_" || return $?
        command date +"%s %Y %m %d %H:%M:%S"
    done
}

___x_cmd_sleep_schd(){
    [ $# -gt 0 ]    ||  set -- --help

    local n=0
    local interval=5

    while [ $# -gt 0 ]; do
        case "$1" in
            -h|--help)      ___x_cmd help -m sleep schd "$@" ; return 0 ;;
            -n)             n="$2" ; arg:2:shift ;;
            -i|--interval)  interval="$2"; arg:2:shift ;;
            --)             shift; break ;;
            *)              break
        esac
    done

    local IFS=" "
    [ $# -gt 0 ] || N=sleep M="Empty command list -> $*" log:ret:64

    local x_
    ___x_cmd humantime tosec_ "$interval" || return $?
    interval="$x_"

    sleep:debug "Sleep in seconds -> [interval=$interval]"

    local err

    local i=0
    while [ "$n" -le 0 ] || [ $((i+1)) -le "$n" ]; do
        "$@"
        err=$?
        case "$err" in
            130)        sleep:info "Schedule interrupted during mission. [SIGINT]" ; return 130 ;;
            0)          ;;
            *)          sleep:info "Scheduled mission fail [exitcode=$err]" ;;
        esac

        # Deprecated.
        [ -z "$___X_CMD_SLEEP_SCHD_END" ]   || {
            sleep:info "Schedule terminated because ___X_CMD_SLEEP_SCHD_END is set"
            ___X_CMD_SLEEP_SCHD_END=
            return 0
        }

        ___x_cmd_cmds_sleep "$interval"     || {
            sleep:info "Schedule interrupted during sleep. [SIGINT]"
            return 130
        }
    done
}
