Flock utility and crontab script

Can anyone enlighten me on the "flock" package in collaboration with "crontab"( options and whether the solution found may be valid), I would like to make sure that a script is executed every minute

cat /etc/crontab/root

#min hour day month day-week command
#0-59 0-23 1-31 1-12 0-6(0=Sunday) exec
* * * * * flock -n /tmp/wan_connect.lock /root/wan_connect

the script checks if there is an internet connection and if it is missing it reconnects it (if necessary just ask and I will also add the script in question)

and sorry if the question may be really stupid...

see these attachments:

Install a desktop linux and read the manual page?

1 Like

the utility is already present in my debian system

as far as the man page is concerned it can also be found on the internet


but perhaps my question has been misunderstood, is the way I chose correct or is there a better way?

Depends on what you are trying to accomplish. Probably just look into ifup script.

I would like to avoid that the script remains blocked for some reason and that there can only be one instance of the script running

Auto translation does not work.
Please examine ifup script which can be called at any rate.

1 Like

I'm sorry but I don't see what you think is simple and/or clear

maybe I'm very stupid... but I don't see a possible solution here

cat /sbin/ifup



if_call() {
        local interface="$1"
        for mode in $modes; do
                ubus call network.interface $mode "{ \"interface\" : \"$interface\" }"

case "$0" in
        *ifdown) modes=down;;
                modes="down up"
        *) echo "Invalid command: $0";;

while :; do
        case "$1" in

[ "$modes" = "down up" ] && ubus call network reload
if [ -n "$ifup_all" ]; then
        for interface in $(ubus -S list 'network.interface.*'); do
                if_call "${interface##network.interface.}"
        ubus -S list "network.interface.$1" > /dev/null || {
                echo "Interface $1 not found"
        if_call "$1"

Auto translation does not work

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.