* [gentoo-user] Difficulties to acchieve a certain time period with fcron
@ 2015-05-29 16:12 Meino.Cramer
2015-05-29 18:30 ` Dimitrios Semitsoglou-Tsiapos
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Meino.Cramer @ 2015-05-29 16:12 UTC (permalink / raw
To: Gentoo
Hi,
probably I have made a knot into my brain...
What I want is, that fcron executes a script every 14 days. It does
not matter, when to execute the script, since I cannot guarantee that
my PC is running exactly at that time.
I tried
&b(1),mailto(root) * * */14 * * /home/user/bin/script.sh
Which "works" according to this: On the 28.th the script was
executed every miinute...
But: If I specivy anything for the minute/hour field, it means:
Do execute the script exeactly THEN. And this in turn I dont want.
Which places my thoughts again right at the beginning of the cyclus...
I am makeing definetly something very wrong here...but I the logic
seems to prevent me to do the rigth ting...
Or I am currently struck with blindness??
Any help will be very appreciated!
;)
Best regards,
Meino
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Difficulties to acchieve a certain time period with fcron
2015-05-29 16:12 [gentoo-user] Difficulties to acchieve a certain time period with fcron Meino.Cramer
@ 2015-05-29 18:30 ` Dimitrios Semitsoglou-Tsiapos
2015-05-30 7:57 ` Alan McKinnon
2015-05-30 20:31 ` [gentoo-user] " Alex Brandt
2 siblings, 0 replies; 6+ messages in thread
From: Dimitrios Semitsoglou-Tsiapos @ 2015-05-29 18:30 UTC (permalink / raw
To: gentoo-user
On 29/05/15 18:12, Meino.Cramer@gmx.de wrote:
> Hi,
>
> probably I have made a knot into my brain...
>
> What I want is, that fcron executes a script every 14 days. It does
> not matter, when to execute the script, since I cannot guarantee that
> my PC is running exactly at that time.
>
> I tried
>
> &b(1),mailto(root) * * */14 * * /home/user/bin/script.sh
>
> Which "works" according to this: On the 28.th the script was
> executed every miinute...
>
> But: If I specivy anything for the minute/hour field, it means:
> Do execute the script exeactly THEN. And this in turn I dont want.
>
I could be wrong, but I believe it behaves this way with this particular
syntax in order to remain functionally compatible with other cron
implementations.
What you're looking for is the "@" syntax, which would transform your
line into one of the following:
@mailto(root) 14d /home/user/bin/script.sh
@mailto(root) 2w /home/user/bin/script.sh
> Which places my thoughts again right at the beginning of the cyclus...
>
> I am makeing definetly something very wrong here...but I the logic
> seems to prevent me to do the rigth ting...
>
> Or I am currently struck with blindness??
>
> Any help will be very appreciated!
> ;)
>
> Best regards,
> Meino
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Difficulties to acchieve a certain time period with fcron
2015-05-29 16:12 [gentoo-user] Difficulties to acchieve a certain time period with fcron Meino.Cramer
2015-05-29 18:30 ` Dimitrios Semitsoglou-Tsiapos
@ 2015-05-30 7:57 ` Alan McKinnon
2015-05-30 16:42 ` [gentoo-user] " James
2015-05-30 20:31 ` [gentoo-user] " Alex Brandt
2 siblings, 1 reply; 6+ messages in thread
From: Alan McKinnon @ 2015-05-30 7:57 UTC (permalink / raw
To: gentoo-user
On 29/05/2015 18:12, Meino.Cramer@gmx.de wrote:
> Hi,
>
> probably I have made a knot into my brain...
>
> What I want is, that fcron executes a script every 14 days. It does
> not matter, when to execute the script, since I cannot guarantee that
> my PC is running exactly at that time.
>
> I tried
>
> &b(1),mailto(root) * * */14 * * /home/user/bin/script.sh
>
> Which "works" according to this: On the 28.th the script was
> executed every miinute...
>
> But: If I specivy anything for the minute/hour field, it means:
> Do execute the script exeactly THEN. And this in turn I dont want.
>
> Which places my thoughts again right at the beginning of the cyclus...
>
> I am makeing definetly something very wrong here...but I the logic
> seems to prevent me to do the rigth ting...
>
> Or I am currently struck with blindness??
Sounds like a job for anacron. What you want to do is way outside what
the various cron daemons were built to do.
Here's how I would do it:
Run a wrapper script once a day (you do not care when exactly). The
wrapper script creates a state file every time it runs the job the says
when it last ran. Each time the script starts, it checks this file and
figures out itself if it needs to run now or not.
--
Alan McKinnon
alan.mckinnon@gmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] Re: Difficulties to acchieve a certain time period with fcron
2015-05-30 7:57 ` Alan McKinnon
@ 2015-05-30 16:42 ` James
2015-05-30 20:15 ` Neil Bothwick
0 siblings, 1 reply; 6+ messages in thread
From: James @ 2015-05-30 16:42 UTC (permalink / raw
To: gentoo-user
Alan McKinnon <alan.mckinnon <at> gmail.com> writes:
> On 29/05/2015 18:12, Meino.Cramer <at> gmx.de wrote:
> > I am makeing definetly something very wrong here...but I the logic
> > seems to prevent me to do the rigth ting...
*cron* are limited. You need advanced logic constructs to achieve what you
want. Bash is most likely your easiest path.
> Sounds like a job for anacron. What you want to do is way outside what
> the various cron daemons were built to do.
> Here's how I would do it:
> Run a wrapper script once a day (you do not care when exactly). The
> wrapper script creates a state file every time it runs the job the says
> when it last ran. Each time the script starts, it checks this file and
> figures out itself if it needs to run now or not.
All good advice. There are many example scripts about time triggering and
counting days to then trigger your desired script. The construct to track
elapsed time that I use, is just a simple "accumulator". Once it is full
then you trigger your script and zero out the accumulator and start it
all over again.... There are many logic constructs that will do what your
want. Just hack away!
When my mesos work is ready for other, there is a fantastic replacement,
call chronos [1] that will fit your needs nicely. Fortunately for embedded
guys like yourself, you'll be able to keep your cluster 'live' on milliwatts
of power on a small embedded board, then trigger relays or such to boot up
other boxes, as the cluster (down to a minimal embedded board) ramps ups to
server your needs. I'm making lots of progress; but the more I get working
the more I discover that I need other codes and modules.....
Maybe you can run the aforementioned anacron on one of your arm boards,
for now?
Maybe if you wrote your script in Haskell [2], one of the really smart guys
would help you debug and get it working (correctly?).....
Have Fun,
James
[1] http://nerds.airbnb.com/introducing-chronos/
[2] http://www.haskellforall.com/2015/01/use-haskell-for-shell-scripting.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Difficulties to acchieve a certain time period with fcron
2015-05-29 16:12 [gentoo-user] Difficulties to acchieve a certain time period with fcron Meino.Cramer
2015-05-29 18:30 ` Dimitrios Semitsoglou-Tsiapos
2015-05-30 7:57 ` Alan McKinnon
@ 2015-05-30 20:31 ` Alex Brandt
2 siblings, 0 replies; 6+ messages in thread
From: Alex Brandt @ 2015-05-30 20:31 UTC (permalink / raw
To: gentoo-user; +Cc: Meino.Cramer
On Friday, May 29, 2015 18:12:52 Meino.Cramer@gmx.de wrote:
> What I want is, that fcron executes a script every 14 days. It does
> not matter, when to execute the script, since I cannot guarantee that
> my PC is running exactly at that time.
I've got a similar cron I run for backups (daily rather than bi-weekly) but it
looks like this:
%nightly,bootrun,random * 2-4 CMD
What this tells fcron is to run nightly (meaning only one run is allowed in an
evening, run at boot if it hasn't run and I just booted in the period, and
randomly select a time between 2:00 and 4:00. Works great for my needs and if
one is missed it gets picked up at boot as it should.
Hope that helps but if not there's more in the man page:
http://fcron.free.fr/doc/en/fcrontab.5.html
Regards,
--
Alex Brandt
Software Developer for Rackspace and Developer for Gentoo
http://blog.alunduil.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-05-30 20:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 16:12 [gentoo-user] Difficulties to acchieve a certain time period with fcron Meino.Cramer
2015-05-29 18:30 ` Dimitrios Semitsoglou-Tsiapos
2015-05-30 7:57 ` Alan McKinnon
2015-05-30 16:42 ` [gentoo-user] " James
2015-05-30 20:15 ` Neil Bothwick
2015-05-30 20:31 ` [gentoo-user] " Alex Brandt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox