cherrycake_janitor_log
database table to store information about the executed tasks.You can create the Janitor table in your database by importing thejanitor.sql
file you'll find in the Cherrycake skeleton repository, under theinstall/database
directory.
src/JanitorTaskMoviesUpdateImdbRating.class.php
like this:executionPeriodicity
key to JANITORTASK_EXECUTION_PERIODICITY_HOURS
, and the periodicityHours
to ["00:00"]
. This will cause this task to run once at each one of the times specified in the periodicityHours
array. In this case, at midnight precisely.JANITORTASK_EXECUTION_PERIODICITY_HOURS
, you can specify more times for tasks to be executed more than once a day. For example, if you set periodicityHours
to ["00:00", "12:00"]
, the task will be executed every day at midnight and at noon.JANITORTASK_EXECUTION_PERIODICITY_EACH_SECONDS
The task will be executed every specified seconds. Seconds are specified in periodicityEachSeconds
config key.JANITORTASK_EXECUTION_PERIODICITY_MINUTES
The task will be executed on the given minutes of each hour. Desired minutes are specified as an array in the periodicityMinutes
config key. For example: [0, 15, 30, 45]
JANITORTASK_EXECUTION_PERIODICITY_HOURS
The task will be executed on the given hours of each day. Desired hours/minute are specified as an array in the periodicityHours
config key in the syntax ["hour:minute", ...]
For example: ["00:00", "10:45", "20:15"]
JANITORTASK_EXECUTION_PERIODICITY_DAYSOFMONTH
The task will be executed on the given days of each month. Desired days/hour/minute are specified as an array in the periodicityDaysOfMonth
config key in the syntax ["[email protected]:minute", ...]
For example: ["[email protected]:00", "[email protected]:30", "[email protected]:00"]
JANITORTASK_EXECUTION_PERIODICITY_ALWAYS
The task will be executed every time Janitor run is called.JANITORTASK_EXECUTION_PERIODICITY_ONLY_MANUAL
The task can only be executed when calling the Janitor run process with an specific task parameter.run
method is the one that will be executed when the task is due, so it's where you should put your task code. Like in our example, if you need to work with core or app modules there, use Engine::loadCoreModule or Engine::loadAppModule.run
method must return an array containing at least one element, being one of the available JANITORTASK_EXECUTION_RETURN_?
constants. You can add a second element containing a description of the task execution result.config/Janitor.config.php
file and adding them to the appJanitorTasks
configuration key.config/Janitor.config.php
would look like this:JanitorTaskJanitorPurge
Performs maintenance tasks related to the Janitor module itself, like purging old log items from the database.JanitorTaskSystemLogPurge
Performs maintenance tasks related to the SystemLog module, like purging old log items from the database.JanitorTaskSystemLogCommit
Commits the SystemLog events stored in the cache shared memory to the database for persistence and for optimal performance.JanitorTaskSessionPurge
Performs maintenance tasks related to the Session module, like purging old sessions.JanitorTaskStatsCommit
Commits the Stats events stored in the cache shared memory to the database for persistence and for optimal performance.JanitorTaskLogCommit
Commits the Log events stored in the cache shared memory to the database for persistence and for optimal performance.janitorRun
must be executed every minute automatically by the operating system in the server. This is usually done by setting up a cron job in Linux that does it by using the Cherrycake Command line interface.When using the Cherrycake Docker project to run your Cherrycake app, this cron job is already set up and running.
cherrycake_janitor_log
, so you can check there to see what's happening in real time.janitorStatus
CLI command, which will show you the current status of all the tasks in your app, plus information about the last time they were executed. It looks like this: