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:
linux, cron
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
https://manpages.debian.org/testing/util-linux/flock.1.en.html
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
#!/bin/sh
ifup_all=
if_call() {
local interface="$1"
for mode in $modes; do
ubus call network.interface $mode "{ \"interface\" : \"$interface\" }"
done
}
case "$0" in
*ifdown) modes=down;;
*ifup)
modes="down up"
;;
*) echo "Invalid command: $0";;
esac
while :; do
case "$1" in
-a)
ifup_all=1
shift
;;
*)
break
;;
esac
done
[ "$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.}"
done
exit
else
ubus -S list "network.interface.$1" > /dev/null || {
echo "Interface $1 not found"
exit
}
if_call "$1"
fi
Auto translation does not work
system
Closed
July 7, 2024, 11:17pm
9
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.