Skip to content

Cronjob

Rainer Sulzbach edited this page Dec 9, 2019 · 13 revisions

Clownfish - cronjob

Jobs can be scheduled in the cronjob list.

Table cf_quartz

attribute description
name Name of job
schedule Crontab schedule string Quartz cron trigger tutorial
site_ref Reference to the site that defines the job
active is the job activated (1) or deactivated (0)

Steps to define a job:

  1. create a template
  2. create a site
  3. create a job
  4. init Clownfish server

When the Clownfish server starts and the property job_support is set to true, it iterates over the cf_quartz table and schedules all activated jobs with the defined rule. If a job is triggered the corresponding site is called to run the linked template.

You should set the job flag of the site in the siteoverview. This indicates, that this site can only be called via the cronjob trigger. When you try to call a job flagged site via the browser, you receive an error message. If you don't flag a site as job, you can trigger that job by calling the site in a browser.

Example job

Following code in a template jobtest will print out the actual date and time.

Now it is: ${.now}

Create the site jobtest in the siteoverview with the template jobtest. In the Misc section you can check the Job flag. If you like to call the site in your browser, then don't check the flag.

On the job section create a new job called jobtest. Put 0 * * ? * * * to the job value field. Set the active flag to true and select the jobtest site in the dropdown list. After creating this job with the New button, the job will be triggered at every minute.

Look at your Clownfish console. You will see the output every minute.

You can build the timer settings easily with the timer dialog. If you are finished with the settings, use the Transfer to job button to set the new job value. Don't forget to press the Edit button to save the new settings. This will trigger the new timer settings.

Clone this wiki locally