With this concept can you create a crontab and handle the Scheduler to schedule your jobs.
Into the crontab can you add Unix like crons. The cron have the following elements:
min, hour, dayOfMonth, month, dayOfWeek. If you want to use a days of month put "*"
in the place of dayOfWeek, and you want to use days of week put "*" in the place
of dayOfMonth.
A structure of one cron element can be:
- - single number (eg.12), sets a concrete value
- - coma-separated list of numbers (eg.2, 7, 10, 25), sets each of these values.
- - interval of numbers (eg.3-7), sets a every value of this interval.
- - "*", sets a all values for attribute.
- - any interval or "*" followed by slash and a number eg.*/3 or 4-8/2,
the number after the slash make the step of the interval.
The values of elements:
- - minutes: 0-59
- - hours: 0-23
- - dayOfMonth: 1-31
- - month: 1-12
- - dayOfWeek: 0-7 (0 and 7 is Sunday)
# The cron is Singleton, you have only one instance on your terminal
$y=Cron.getInstance
# Every Monday on 0.10, 6.10, 12.10, 18.10 will execute the "Google ..." script
Cron.addTask("10 0-23/6 * * 1", "Google rsearch Antal Attila atech")
# Every 20th day of month on 14.30 will execute the "Google ..." script
# and assigns the returned task id to $t (is Integer)
$t = Cron.addTask("30 14 20 * *", "Google rsearch Gnome 2.0 distribution")
# or if using the same cron you want to execute the method
# onlytest from Test concept with parameter "Hello World!"
$ser typeof Series
$ser.add("Hello World!")
Cron.addTask("30 14 20 * *", "Test.onlytest", $ser)
# looking after my cron tasks
print $y.toXML
# getting the tasks into the series
$tasks = Cron.getTasks
# Ugly task with id=1 I remove it
Cron.removeTask(1)
# How many tasks I have?
print "" + Cron.getTasks@length
# Be happy I starting the scheduler
Cron.start
# The system is hanging up and holds the scheduler to work
System.pause(0)
# Is something working bad or need to shut down the scheduler
Cron.stop
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Label: | task |
Type: | Series |
Is Static: | false |
Is Hidden: | false |
Is Multi: | false |
Show Empty: | true |
Task element to hold informations with its attributes
Parameters: |
$timeString : | Cron string |
$task : | Execution string in order by ConceptName followed by it self attributes |
|
Exceptions: |
addTriggerException :
(Error) |
If unable to add trigger to the Cron concept. |
cronStringException :
(Error) |
If the cron String isn't valid. |
Adding task into your tasks.
Cron.addTask("10 0-23/6 * * 1", "Google rsearch regexp syntax flags")
This will execute the "Google rsearch ..." command every Monday on 0.10, 6.10, 12.10, 18.10
Parameters: |
$timeString : | Cron string |
$task : | Execution string like an mn8 static method call, Concept.method |
$ser : | A series for method parameters |
|
Exceptions: |
addTriggerException :
(Error) |
If unable to add trigger to the Cron concept. |
cronStringException :
(Error) |
If the cron String isn't valid. |
Adding task into your tasks.
$ser typeod Series
$ser.add("Hello World")
Cron.addTask("10 0-23/6 * * 1", "Echo.echoString", $ser)
This will execute the "Echo echoString" command with a "Hello World" parameter, every Monday on 0.10, 6.10, 12.10, 18.10
The cron concept is Singleton, with this method you can get an instance.
Cron.addTask("10 0-23/6 * * 1", "Google rsearch regexp syntax flags")
Cron.getInstance
-- the result is --
Cron
tasks
task
id: 1 timeString: 10 0-23/6 * * 1 CommandString: Google rsearch regexp syntax flags
Returns all the tasks.
Cron.addTask("10 0-23/6 * * 1", "Google rsearch regexp syntax flags")
Cron.addTask("30 14 20 * *", "Google rsearch Gnome 2.0 distribution")
Cron.getTasks
-- the result is --
task
id: 1 timeString: 10 0-23/6 * * 1 CommandString: Google rsearch regexp syntax flags
task
id: 2 timeString: 30 14 20 * * CommandString: Google rsearch Gnome 2.0 distribution
Parameters: |
$taskId : | Task id, what returns the addTask method |
|
Remove the specified task.
Cron.addTask("10 0-23/6 * * 1", "Google rsearch regexp syntax flags")
Cron.addTask("30 14 20 * *", "Google rsearch Gnome 2.0 distribution")
Cron.removeTask(1)
Cron.getTasks
-- the result is --
task
id: 2 timeString: 30 14 20 * * CommandString: Google rsearch Gnome 2.0 distribution
Exceptions: |
onStartException :
(Error) |
If the scheduler can't be started. |
Starting the scheduler.
Cron.addTask("10 0-23/6 * * 1", "Google rsearch regexp syntax flags")
Cron.addTask("30 14 20 * *", "Google rsearch Gnome 2.0 distribution")
Cron.start
Stops the scheduler.
Cron.stop