Let's say I define a scheduled task in openwrt to activate once every 10 minutes, is there a way to define this task to activate only once, and not on repeat every 10 minutes?
I am using openwrt version 18.06
Let's say I define a scheduled task in openwrt to activate once every 10 minutes, is there a way to define this task to activate only once, and not on repeat every 10 minutes?
I am using openwrt version 18.06
which one is it ?
sleep 600; execute task script ?
time to upgrade ?
Thing is, I read in the forum that sleep command should not be used with long periods of time, especially in startup, so where would be a safe place to run sleep 600?
and unfortunately, there is no better openwrt version for my hardware, believe me, I tried looking. I am using a 8devices komikan chip
I can imagine it can behave unreliably, if the device clock get synced during the sleep.
loop the date/time, when the year's 202? ( = in sync), start your sleep.
Excellent, then use cron as you originally noted.
But personally, I'd use the startup script. Are you sure you didn't confuse the two?
Can you link that post?
But cron will keep running the command every 10 minutes, not just once, right?
Write a script so it doesn't repeat.
e.g.
$already_ran_foo
default 0, set to 1 after script runsyou can create a semaphor file
run 1st time and create file /tmp/somefile.name during execution
run every other time, check if /tmp/somefile.name exists, exit.
Frollic already asked this, but what you actually want regarding the timing?
"every 10 minutes" and "activate only once, and not on repeat every 10 minutes" sound quite different.
Do you want something that
Cron plus semaphore file, like suggested by frollic and lleachii, would be right for the last option.
Note that the benefit of creating the semaphore file in /tmp (=ramdisk), is that it will get automatically cleared at the next boot.
For that, I'd probably use the semaphore to tell me when it ran, like this.
#!/bin/sh
semaphore="/var/run/run_once.status"
if [ -e "$semaphore" ] ; then
exit 0
fi
echo "Starting..."
ls
echo "Done."
date > "$semaphore"
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.