Discussion:
LiveCode equivalent to 'cron' for automated background functions?
Keith Clarke via use-livecode
2018-11-28 16:14:55 UTC
Permalink
Folks,
Please can anyone steer me towards the dictionary keyword equivalent to ‘cron' jobs for initiating time-based background functions, along the lines of…

on TimeAt pHour pMinute pSecond
do stuff
end TimeAt

Thanks
Keith
Mike Kerner via use-livecode
2018-11-28 17:02:49 UTC
Permalink
LC is single-threaded so CRON is a little tricky. I have code that works
with those limitations. I suppose I should repo it. Some day I might even
get the secondary process part working.

On Wed, Nov 28, 2018 at 11:15 AM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Folks,
Please can anyone steer me towards the dictionary keyword equivalent to
‘cron' jobs for initiating time-based background functions, along the lines
of…
on TimeAt pHour pMinute pSecond
do stuff
end TimeAt
Thanks
Keith
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
Mike Kerner via use-livecode
2018-11-28 17:30:55 UTC
Permalink
In the meantime, there are two commands to have a look at if you want to
have a crack at rolling your own
send and do
send "doSomething" to me in 60 seconds
then there is a way to see if you're interrupting an asynchronous activity
pendingMessages
Post by Mike Kerner via use-livecode
LC is single-threaded so CRON is a little tricky. I have code that works
with those limitations. I suppose I should repo it. Some day I might even
get the secondary process part working.
On Wed, Nov 28, 2018 at 11:15 AM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Folks,
Please can anyone steer me towards the dictionary keyword equivalent to
‘cron' jobs for initiating time-based background functions, along the lines
of…
on TimeAt pHour pMinute pSecond
do stuff
end TimeAt
Thanks
Keith
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
Keith Clarke via use-livecode
2018-11-28 17:43:23 UTC
Permalink
Thanks Mike, I was aware of ‘do’ but hadn’t used ’send’, so not seen its timer aspect.

The examples in the dictionary look potentially useful for a couple of lightweight activities I’d like to have ticking-over in the background on my LC Server, pending page visits.
Best,
Keith
Post by Mike Kerner via use-livecode
In the meantime, there are two commands to have a look at if you want to
have a crack at rolling your own
send and do
send "doSomething" to me in 60 seconds
then there is a way to see if you're interrupting an asynchronous activity
pendingMessages
Post by Mike Kerner via use-livecode
LC is single-threaded so CRON is a little tricky. I have code that works
with those limitations. I suppose I should repo it. Some day I might even
get the secondary process part working.
On Wed, Nov 28, 2018 at 11:15 AM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Folks,
Please can anyone steer me towards the dictionary keyword equivalent to
‘cron' jobs for initiating time-based background functions, along the lines
of…
on TimeAt pHour pMinute pSecond
do stuff
end TimeAt
Thanks
Keith
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Mike Kerner via use-livecode
2018-11-28 17:57:37 UTC
Permalink
oh, yeah, and have a look at waitDepth

On Wed, Nov 28, 2018 at 12:43 PM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Thanks Mike, I was aware of ‘do’ but hadn’t used ’send’, so not seen its
timer aspect.
The examples in the dictionary look potentially useful for a couple of
lightweight activities I’d like to have ticking-over in the background on
my LC Server, pending page visits.
Best,
Keith
On 28 Nov 2018, at 17:30, Mike Kerner via use-livecode <
In the meantime, there are two commands to have a look at if you want to
have a crack at rolling your own
send and do
send "doSomething" to me in 60 seconds
then there is a way to see if you're interrupting an asynchronous
activity
pendingMessages
Post by Mike Kerner via use-livecode
LC is single-threaded so CRON is a little tricky. I have code that
works
Post by Mike Kerner via use-livecode
with those limitations. I suppose I should repo it. Some day I might
even
Post by Mike Kerner via use-livecode
get the secondary process part working.
On Wed, Nov 28, 2018 at 11:15 AM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Folks,
Please can anyone steer me towards the dictionary keyword equivalent to
‘cron' jobs for initiating time-based background functions, along the
lines
Post by Mike Kerner via use-livecode
Post by Keith Clarke via use-livecode
of…
on TimeAt pHour pMinute pSecond
do stuff
end TimeAt
Thanks
Keith
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
Andre Alves Garzia via use-livecode
2018-11-30 12:10:14 UTC
Permalink
Keith,
Post by Keith Clarke via use-livecode
The examples in the dictionary look potentially useful for a couple of lightweight activities I’d like to have ticking-over in the background on my LC Server, pending page visits.
You shouldn't have the CGI engine hogging up like that, thats not how
web stuff is supposed to work. First, Apache (or whatever you're
running) will kill the process after some seconds if it fails to exit on
its own. Second, it is a waste of resources. Imagine that you have this
running for every request that is made, so each time a user requests
your site, your LC Server engine hangs in the background for a while,
hogging up system resources.

LC Servers should reply as fast as possible and then exit. If you need a
long running process to do some administrative stuff regularly, then,
consider building a little script and running that as a real proper
cronjob on the server, not tied to visits.

Cheers

andre
Keith Clarke via use-livecode
2018-11-30 12:37:45 UTC
Permalink
Thanks Andre - good call.
Following others’ reminders of the single-threaded nature of LCS, I’m trying to rethink data flows as on-demand, to avoid all background tasks.
Best,
Keith
Post by Andre Alves Garzia via use-livecode
Keith,
Post by Keith Clarke via use-livecode
The examples in the dictionary look potentially useful for a couple of lightweight activities I’d like to have ticking-over in the background on my LC Server, pending page visits.
You shouldn't have the CGI engine hogging up like that, thats not how web stuff is supposed to work. First, Apache (or whatever you're running) will kill the process after some seconds if it fails to exit on its own. Second, it is a waste of resources. Imagine that you have this running for every request that is made, so each time a user requests your site, your LC Server engine hangs in the background for a while, hogging up system resources.
LC Servers should reply as fast as possible and then exit. If you need a long running process to do some administrative stuff regularly, then, consider building a little script and running that as a real proper cronjob on the server, not tied to visits.
Cheers
andre
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Sannyasin Brahmanathaswami via use-livecode
2018-11-30 16:54:17 UTC
Permalink
Been using LC scripts on the server for "like 20 years."

But run on the cron of the server itself.

Brahmanathaswami


On 11/30/18, 2:37 AM, "use-livecode on behalf of Keith Clarke via use-livecode" <use-livecode-***@lists.runrev.com on behalf of use-***@lists.runrev.com> wrote:

Thanks Andre - good call.
Following others’ reminders of the single-threaded nature of LCS, I’m trying to rethink data flows as on-demand, to avoid all background tasks.
Best,
Keith

Richard Gaskin via use-livecode
2018-11-28 20:45:38 UTC
Permalink
Post by Keith Clarke via use-livecode
Please can anyone steer me towards the dictionary keyword equivalent
to ‘cron' jobs for initiating time-based background functions, along
the lines of…
on TimeAt pHour pMinute pSecond
do stuff
end TimeAt
You can do it with LC, but not as a CGI, as LC Server is most commonly
used. CGIs boot a scripting engine, the engine processes the request,
sends a reply, and dies, each time it's called. Keeps things simple and
discrete, but isn't well suited for an always-on process like a cron
substitute.

Shared hosts generally don't allow always-on processes, but if you're
running on a VPS or dedicated box you have the freedom to do anything
you want. For such cases "send <msg> in <time>" works well, if you set
up the process to boot with the machine and build a means of interacting
with it while it's running.

If you've seen LiveNet you've seen it in action: I have a box in the
corner of my office that aggregates RSS feeds for our community and
packages them up and posts the result to a public server for display in
LiveNet. It's been running every few minutes without interruption for
years.

But I did it only because it was a fun exercise at the time, and if I
had to do it over again I'd just use cron - simpler, leaner, more portable.

FWIW, cron is for periodic tasks. If you need a one-off at a specific
time see at.

But can be managed from the command line, which means you can drive them
from LC if needed through the shell function.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
***@FourthWorld.com http://www.FourthWorld.com
Alex Tweedly via use-livecode
2018-11-28 21:42:21 UTC
Permalink
FWIW, cron is for periodic tasks.  If you need a one-off at a specific
time see at.
But can be managed from the command line, which means you can drive
them from LC if needed through the shell function.
And. conversely, you can drive LC from cron - i.e. to schedule something
regular, just use cron, and make the cron task be something like

wget https://mydomain.com/index.lc/domynightlytask

so you get to script the task in your usual way (e.g. within
revigniter), and do the scheduling with cron (generally accessible from
cPanel as well as shell).

Alex.
Richard Gaskin via use-livecode
2018-11-28 21:51:48 UTC
Permalink
Post by Alex Tweedly via use-livecode
Post by Richard Gaskin via use-livecode
FWIW, cron is for periodic tasks. If you need a one-off at a
specific time see at.
But can be managed from the command line, which means you can drive
them from LC if needed through the shell function.
And. conversely, you can drive LC from cron - i.e. to schedule
something regular, just use cron, and make the cron task be something
like
wget https://mydomain.com/index.lc/domynightlytask
so you get to script the task in your usual way (e.g. within
revigniter), and do the scheduling with cron (generally accessible
from cPanel as well as shell).
And for local tasks:

~/somescript.lc

...where line 1 of somescript.lc is:

#!/path/to/your/copy/of/livecodeserver


Or launch the engine and specify the script in the command line:

~/livecode-server somescript.lc


Lots of flexibility mixing and matching LC with other tools to make the
best use of what each brings to the table.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
***@FourthWorld.com http://www.FourthWorld.com
Tom Glod via use-livecode
2018-11-29 04:56:42 UTC
Permalink
I did a multi-core processing presentation with livecode at the global
conference.

running long shell commands is one of the use cases for such a setup.

https://github.com/makeshyft-tom-g/livecode-multicore-library

might be an option here.

On Wed, Nov 28, 2018 at 5:20 PM Richard Gaskin via use-livecode <
Post by Richard Gaskin via use-livecode
Post by Alex Tweedly via use-livecode
Post by Richard Gaskin via use-livecode
FWIW, cron is for periodic tasks. If you need a one-off at a
specific time see at.
But can be managed from the command line, which means you can drive
them from LC if needed through the shell function.
And. conversely, you can drive LC from cron - i.e. to schedule
something regular, just use cron, and make the cron task be something
like
wget https://mydomain.com/index.lc/domynightlytask
so you get to script the task in your usual way (e.g. within
revigniter), and do the scheduling with cron (generally accessible
from cPanel as well as shell).
~/somescript.lc
#!/path/to/your/copy/of/livecodeserver
~/livecode-server somescript.lc
Lots of flexibility mixing and matching LC with other tools to make the
best use of what each brings to the table.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
Keith Clarke via use-livecode
2018-11-29 08:49:16 UTC
Permalink
Thanks for the really useful responses Richard, Alex & Tom - great to know the art of the possible.
I think most of my current use cases will be supported by send with time, as they’re more lightweight ’tick-over’ activities than big batch jobs.
Best,
Keith
Post by Richard Gaskin via use-livecode
Post by Alex Tweedly via use-livecode
Post by Richard Gaskin via use-livecode
FWIW, cron is for periodic tasks. If you need a one-off at a
specific time see at.
But can be managed from the command line, which means you can drive
them from LC if needed through the shell function.
And. conversely, you can drive LC from cron - i.e. to schedule
something regular, just use cron, and make the cron task be something
like
wget https://mydomain.com/index.lc/domynightlytask
so you get to script the task in your usual way (e.g. within
revigniter), and do the scheduling with cron (generally accessible
from cPanel as well as shell).
~/somescript.lc
#!/path/to/your/copy/of/livecodeserver
~/livecode-server somescript.lc
Lots of flexibility mixing and matching LC with other tools to make the best use of what each brings to the table.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Mike Kerner via use-livecode
2018-11-29 14:22:56 UTC
Permalink
@tom
Yeah, that was a nifty demonstration of how to get around
single-threadedness, especially after Mark and I had been talking about
that very topic for a week or so. I was thinking that it would be cool to
attach various LC externals and libraries to make a robust way to implement
some better fault tolerance.

On Thu, Nov 29, 2018 at 3:49 AM Keith Clarke via use-livecode <
Post by Keith Clarke via use-livecode
Thanks for the really useful responses Richard, Alex & Tom - great to know
the art of the possible.
I think most of my current use cases will be supported by send with time,
as they’re more lightweight ’tick-over’ activities than big batch jobs.
Best,
Keith
On 28 Nov 2018, at 21:51, Richard Gaskin via use-livecode <
Post by Alex Tweedly via use-livecode
Post by Richard Gaskin via use-livecode
FWIW, cron is for periodic tasks. If you need a one-off at a
specific time see at.
But can be managed from the command line, which means you can drive
them from LC if needed through the shell function.
And. conversely, you can drive LC from cron - i.e. to schedule
something regular, just use cron, and make the cron task be something
like
wget https://mydomain.com/index.lc/domynightlytask
so you get to script the task in your usual way (e.g. within
revigniter), and do the scheduling with cron (generally accessible
from cPanel as well as shell).
~/somescript.lc
#!/path/to/your/copy/of/livecodeserver
~/livecode-server somescript.lc
Lots of flexibility mixing and matching LC with other tools to make the
best use of what each brings to the table.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
and did a little diving.
And God said, "This is good."
Loading...