PHP 클래스 CronTask, glpi

It has all necessary methods to set time schedule of the task. By default schedule is equal to original cron's: '* * * * *' that means to run specified console command every minute. Original cron syntax is supported for methods hour(), minute(), day(), month(), dayOfWeek(), cron(). By calling unique() method you can set flag for task to be unique. It means that if task already running and it's time to run it again - new instance will not be executed (warning message would be added to logs). You can combine any methods to set desired schedule. For example, if you want to run command 'import' with action 'products' and params '--updateAll=1' every day at 18:00, you need to create next task instance: $task = new CronTask('import', 'products', array('updateAll' => 1)); $task->name('Import products (daily@18:00)')->daily()->hour(18); How to add and run task see CronService class description.
저자: Vadym Stepanov ([email protected])
파일 보기 프로젝트 열기: glpi-project/glpi 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$dohistory From CommonDBTM
$rightname

공개 메소드들

메소드 설명
Register ( $itemtype, $name, $frequency, $options = [] ) : boolean Register new task for plugin (called by plugin during install)
Unregister ( $plugin ) : boolean Unregister tasks for a plugin (call by glpi after uninstall)
addVolume ( $volume ) Increase the currently proccessed volume of a running task
callCron ( ) : nothing Call cron if time since last launch elapsed
callCronForce ( ) : boolean Call cron without time check
canDelete ( )
cleanDBonPurge ( )
cronCheckUpdate ( $task ) Cron job to check if a new version is available
cronCircularlogs ( $task ) Circular logs
cronGraph ( $task ) Garbage collector for cleaning graph files
cronInfo ( $name ) : array get Cron description parameter for this class
cronLogs ( $task ) Clean log cron function
cronOptimize ( $task ) Clean log cron function
cronSession ( $task ) Garbage collector for expired file session
cronTemp ( $task ) Garbage collector for cleaning tmp files
cronWatcher ( $task ) Check zombie crontask
defineTabs ( $options = [] )
dropdownFrequency ( $name, $value ) Dropdown for frequency (interval between 2 actions)
dropdownState ( $name, $value, $display = true ) : nothing Dropdown of state
end ( $retcode ) : boolean Start a task, timer, stat, log, .
getDescription ( $id ) : string Translate task description
getForbiddenActionsForMenu ( )
getForbiddenStandardMassiveAction ( )
getFromDBbyName ( $itemtype, $name ) : true Read a Crontask by its name
getModeName ( $mode ) : string Translate Mode to string
getNeedToRun ( $mode, $name = '' ) : false read the first task which need to be run by cron
getParameterDescription ( ) : string Translate task parameter description
getSearchOptions ( )
getSpecificMassiveActions ( $checkitem = NULL )
getSpecificValueToDisplay ( $field, $values, array $options = [] )
getSpecificValueToSelect ( $field, $name = '', $values = '', array $options = [] )
getStateName ( $state ) : string Translate state to string
getTypeName ( $nb )
getUsedItemtypes ( ) : array Get all itemtypes used
isDisabled ( ) : integer Give a task state
launch ( $mode, $max = 1, $name = '' ) : the Launch the need cron tasks
log ( $content ) Add a log message for a running task
processMassiveActionsForOneItemtype ( MassiveAction $ma, CommonDBTM $item, array $ids )
resetDate ( ) reset the next launch date => for a launch as soon as possible
resetState ( ) reset the current state
setVolume ( $volume ) Set the currently proccessed volume of a running task
showForm ( $ID, $options = [] ) : Nothing Print the contact form
showHistory ( ) : nothing Display list of a runned tasks
showHistoryDetail ( $logid ) : nothing Display detail of a runned task
showStatistics ( ) : nothing Display statistics of a task
signal ( $signo ) Signal handler callback
start ( ) : boolean Start a task, timer, stat, log, .

비공개 메소드들

메소드 설명
get_lock ( ) : boolean Get a global database lock for cron
release_lock ( ) Release the global database lock

메소드 상세

Register() 공개 정적인 메소드

Register new task for plugin (called by plugin during install)
public static Register ( $itemtype, $name, $frequency, $options = [] ) : boolean
$itemtype itemtype of the plugin object
$name of the task
$frequency of execution
$options array of optional options (state, mode, allowmode, hourmin, hourmax, logs_lifetime, param, comment)
리턴 boolean for success

Unregister() 공개 정적인 메소드

Unregister tasks for a plugin (call by glpi after uninstall)
public static Unregister ( $plugin ) : boolean
$plugin : name of the plugin
리턴 boolean for success

addVolume() 공개 메소드

Increase the currently proccessed volume of a running task
public addVolume ( $volume )
$volume

callCron() 정적인 공개 메소드

Call cron if time since last launch elapsed
static public callCron ( ) : nothing
리턴 nothing

callCronForce() 정적인 공개 메소드

Call cron without time check
static public callCronForce ( ) : boolean
리턴 boolean : true if launched

canDelete() 정적인 공개 메소드

static public canDelete ( )

cleanDBonPurge() 공개 메소드

public cleanDBonPurge ( )

cronCheckUpdate() 정적인 공개 메소드

Cron job to check if a new version is available
static public cronCheckUpdate ( $task )
$task for log

cronCircularlogs() 정적인 공개 메소드

Circular logs
static public cronCircularlogs ( $task )
$task for log

cronGraph() 정적인 공개 메소드

Garbage collector for cleaning graph files
static public cronGraph ( $task )
$task for log

cronInfo() 정적인 공개 메소드

get Cron description parameter for this class
static public cronInfo ( $name ) : array
$name string name of the task
리턴 array of string

cronLogs() 정적인 공개 메소드

Clean log cron function
static public cronLogs ( $task )
$task instance of CronTask

cronOptimize() 정적인 공개 메소드

Clean log cron function
static public cronOptimize ( $task )
$task for log

cronSession() 정적인 공개 메소드

Garbage collector for expired file session
static public cronSession ( $task )
$task for log

cronTemp() 정적인 공개 메소드

Garbage collector for cleaning tmp files
static public cronTemp ( $task )
$task for log

cronWatcher() 정적인 공개 메소드

Check zombie crontask
static public cronWatcher ( $task )
$task for log

defineTabs() 공개 메소드

public defineTabs ( $options = [] )

dropdownFrequency() 공개 메소드

Dropdown for frequency (interval between 2 actions)
public dropdownFrequency ( $name, $value )
$name select name
$value default value (default 0)

dropdownState() 정적인 공개 메소드

Dropdown of state
static public dropdownState ( $name, $value, $display = true ) : nothing
$name select name
$value default value (default 0)
$display display or get string (true by default)
리턴 nothing (display)

end() 공개 메소드

..
public end ( $retcode ) : boolean
$retcode : <0 : need to run again, 0:nothing to do, >0:ok
리턴 boolean : true if ok (not start by another)

getDescription() 공개 메소드

Translate task description
public getDescription ( $id ) : string
$id integer ID of the crontask
리턴 string

getForbiddenActionsForMenu() 정적인 공개 메소드

또한 보기: CommonGLPI::getForbiddenActionsForMenu()
static public getForbiddenActionsForMenu ( )

getForbiddenStandardMassiveAction() 공개 메소드

getFromDBbyName() 공개 메소드

Used by plugins to load its crontasks
public getFromDBbyName ( $itemtype, $name ) : true
$itemtype itemtype of the crontask
$name name of the task
리턴 true if succeed else false

getModeName() 공개 정적인 메소드

Translate Mode to string
public static getModeName ( $mode ) : string
$mode integer
리턴 string

getNeedToRun() 공개 메소드

read the first task which need to be run by cron
public getNeedToRun ( $mode, $name = '' ) : false
$mode >0 retrieve task configured for this mode <0 retrieve task allowed for this mode (force, no time check) (default 0)
$name one specify action (default '')
리턴 false if no task to run

getParameterDescription() 공개 메소드

Translate task parameter description
public getParameterDescription ( ) : string
리턴 string

getSearchOptions() 공개 메소드

public getSearchOptions ( )

getSpecificMassiveActions() 공개 메소드

또한 보기: CommonDBTM::getSpecificMassiveActions()
public getSpecificMassiveActions ( $checkitem = NULL )

getSpecificValueToDisplay() 정적인 공개 메소드

static public getSpecificValueToDisplay ( $field, $values, array $options = [] )
$options array

getSpecificValueToSelect() 정적인 공개 메소드

static public getSpecificValueToSelect ( $field, $name = '', $values = '', array $options = [] )
$field
$name (default '')
$values (default '')
$options array array

getStateName() 공개 정적인 메소드

Translate state to string
public static getStateName ( $state ) : string
$state integer
리턴 string

getTypeName() 정적인 공개 메소드

static public getTypeName ( $nb )

getUsedItemtypes() 정적인 공개 메소드

Get all itemtypes used
static public getUsedItemtypes ( ) : array
리턴 array of itemtypes

isDisabled() 공개 메소드

Give a task state
public isDisabled ( ) : integer
리턴 integer 0 : task is enabled if disable : 1: by config, 2: by system lock, 3: by plugin

launch() 공개 정적인 메소드

Launch the need cron tasks
public static launch ( $mode, $max = 1, $name = '' ) : the
$mode (internal/external, <0 to force)
$max number of task to launch (default 1)
$name of task to run (default '')
리턴 the name of last task launched

log() 공개 메소드

Add a log message for a running task
public log ( $content )
$content

processMassiveActionsForOneItemtype() 정적인 공개 메소드

또한 보기: CommonDBTM::processMassiveActionsForOneItemtype()
static public processMassiveActionsForOneItemtype ( MassiveAction $ma, CommonDBTM $item, array $ids )
$ma MassiveAction
$item CommonDBTM
$ids array

resetDate() 공개 메소드

reset the next launch date => for a launch as soon as possible
public resetDate ( )

resetState() 공개 메소드

reset the current state
public resetState ( )

setVolume() 공개 메소드

Set the currently proccessed volume of a running task
public setVolume ( $volume )
$volume

showForm() 공개 메소드

Print the contact form
public showForm ( $ID, $options = [] ) : Nothing
$ID integer ID of the item
$options array - target filename : where to go when done. - withtemplate boolean : template or basic item
리턴 Nothing (display)

showHistory() 공개 메소드

Display list of a runned tasks
public showHistory ( ) : nothing
리턴 nothing

showHistoryDetail() 공개 메소드

Display detail of a runned task
public showHistoryDetail ( $logid ) : nothing
$logid : crontasklogs_id
리턴 nothing

showStatistics() 공개 메소드

Display statistics of a task
public showStatistics ( ) : nothing
리턴 nothing

signal() 공개 메소드

Signal handler callback
부터: 9.1
public signal ( $signo )

start() 공개 메소드

..
public start ( ) : boolean
리턴 boolean : true if ok (not start by another)

프로퍼티 상세

$dohistory 공개적으로 프로퍼티

From CommonDBTM
public $dohistory

$rightname 정적으로 공개적으로 프로퍼티

static public $rightname