The Cron service is a thin wrapper of the Cron4J project. The purpose is to provide a scheduling service which can send any message to any other service at a predetermined interval. It will provide scheduling for MyRobotLab's auto-update feature. Some other applications include turning lights, sprinklers, coffee machines, or other appliances on or off at regular intervals.
A thin service wrapper for the most excellent Cron4J project.
References:
Example code (from branch develop):
# The following script will send a quote to a Log and Python every minute
from datetime import datetime
cron = runtime.start('cron', 'Cron')
log = runtime.start('log', 'Log')
speech = runtime.start("speech","MarySpeech")
# add a task which sends text to the log service Log.log(string) every minute
cron.addTask('* * * * *','log','log', 'hello sir, time for your coffee')
# add a task to send text to a python function every minute
cron.addTask('* * * * *','python','doThisEveryMinute', 'hello sir, time for your coffee')
print ('now is', datetime.now())
def doThisEveryMinute(text):
print (datetime.now())
print (datetime.time(datetime.now()),text)
speech.speak(text)
listOfTasks = cron.getCronTasks()
for i in listOfTasks:
print(i.name, i.cronPattern, i.method)
Example configuration (from branch develop):
!!org.myrobotlab.service.config.ServiceConfig
listeners: null
peers: null
type: Cron
Here is the corrected
Thanks Alessandruino
Thanks Alessandruino !
Corrected...
Updated py script
Hi
I seems like the Cron service has changed since the sample script was created.
I changed the syntax to match the current verison of Cron