WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\framework\cron

abstract class AbstractJob

Class Attributes Summary

const ANY_VALA constant that indicates a sub cron expression is of type 'multi-value'.const INV_VALA constant that indicates a sub cron expression is invalid.const MONTHS_NAMESAn associative array which holds the names and the numbers of year months.const RANGE_VALA constant that indicates a sub cron expression is of type 'range'.const SPECIFIC_VALA constant that indicates a sub cron expression is of type 'specific value'.const STEP_VALA constant that indicates a sub cron expression is of type 'step value'.const WEEK_DAYSAn associative array which holds the names and the numbers of week days.

Class Methods Summary

public function __construct(string$jobName, string$when, string$description)Creates new instance of the class.public function addExecutionArg(string|JobArgument$nameOrObj)Adds new execution argument.public function addExecutionArgs(array$argsArr)Adds multiple execution arguments at one shot.public abstract function afterExec()Run some routines after the job is executed.public function cron(string$when)Schedules a job using specific cron expression.public function dailyAt(int$hour, int$minute)Schedules a cron job to run daily at specific hour and minute.public function everyHour()Schedules a cron job to run every hour.public function everyMonthOn(int$dayNum, string$time)Schedules a cron job to run every month on specific day and time.public function exec(boolean$force)Execute the event which should run when it is time to execute the job.public abstract function execute()Execute the job.public function getArgValue(string$name)Returns the value of a custom execution argument.public function getArgument(string$argName)Returns job argument as an object given its name.public function getArguments()Returns an array that holds execution arguments of the job.public function getCommand()Returns the command that was used to execute the job.public function getDescription()Returns job description.public function getExecArgs()Returns an associative array that contains the values of custom execution parameters.public function getExecArgsNames()Returns an array that contains the names of added custom execution attributes.public function getExpression()Returns the cron expression which is associated with the job.public function getJobDetails()Returns an associative array which contains details about the timings at which the job will be executed.public function getJobName()Returns the name of the job.public function hasArg(string$name)Checks if an argument with specific name belongs to the job or not.public function isDayOfMonth()Checks if current day of month in time is a day at which the job must be executed.public function isDayOfWeek()Checks if current day of week in time is a day at which the job must be executed.public function isForced()Checks if the job is forced to execute or not.public function isHour()Checks if current hour in time is an hour at which the job must be executed.public function isMinute()Checks if current minute in time is a minute at which the job must be executed.public function isMonth()Checks if current month in time is a month at which the job must be executed.public function isSuccess()Returns true if the job was executed successfully.public function isTime()Checks if its time to execute the job or not.public abstract function onFail()Run some routines if the job is executed and failed to completed successfully.public function onMonth(int|string$monthNameOrNum, int$dayNum, string$time)Schedules a job to run at specific day and time in a specific month.public abstract function onSuccess()Run some routines if the job is executed and completed successfully.public function setCommand(CronCommand$command)Associate the job with the command that was used to execute the job.public function setDescription(string$desc)Sets job description.public function setJobName(string$name)Sets an optional name for the job.public function toJSON()public function weeklyOn(int$dayNameOrNum, string$time)Schedules a job to run weekly at specific week day and time.

Class Attributes Details

const ANY_VALA constant that indicates a sub cron expression is of type 'multi-value'. const INV_VALA constant that indicates a sub cron expression is invalid. const MONTHS_NAMESAn associative array which holds the names and the numbers of year months. const RANGE_VALA constant that indicates a sub cron expression is of type 'range'. const SPECIFIC_VALA constant that indicates a sub cron expression is of type 'specific value'. const STEP_VALA constant that indicates a sub cron expression is of type 'step value'. const WEEK_DAYSAn associative array which holds the names and the numbers of week days.

Class Methods Details

public function __construct(string$jobName, string$when, string$description)Creates new instance of the class.

Parameters:

  • string $jobName The name of the job.
  • string $when A cron expression. An exception will be thrown if the given expression is invalid. Default is ' ' which means run the job every minute.
  • string $description A description for the job. Shown in CRON web interface or CLI.
public function addExecutionArg(string|JobArgument$nameOrObj)
Adds new execution argument. An execution argument is an argument that can be supplied to the job in case of force execute. They will appear in cron control panel. They also can be provided to the job when executing it throw CLI as 'arg-name="argVal". The argument name must follow the following rules:
  • Must be non-empty string.
  • Must not contain '#', '?', '&', '=' or space.

Parameters:

public function addExecutionArgs(array$argsArr)Adds multiple execution arguments at one shot.

Parameters:

  • array $argsArr An array that contains the names of the arguments. This also can be an associative array. The indices are arguments names and the values are argument options.
public abstract function afterExec()Run some routines after the job is executed. The developer can implement this method to perform some actions after the job is executed. Note that the method will get executed if the job is failed or successfully completed. It is optional to implement that method. The developer can leave the body of the method empty.public function cron(string$when)
Schedules a job using specific cron expression. For more information on cron expressions, go to https://en.wikipedia.org/wiki/Cron#CRON_expression. Note that the method does not support year field. This means the expression will have only 5 fields. Notes about the expression:
  • Step values are not supported for months.
  • Step values are not supported for day of week.
  • Step values are not supported for day of month.

Parameters:

  • string $when A cron expression (such as '8 15 1'). Default is ' ' which means run the job every minute.
Returns: booleanIf the given cron expression is valid, the method will set the time of cron job as specified by the expression and return true. If the expression is invalid, the method will return false.
public function dailyAt(int$hour, int$minute)Schedules a cron job to run daily at specific hour and minute. The job will be executed every day at the given hour and minute. The function uses 24 hours mode. If no parameters are given, The default time is 00:00 which means that the job will be executed daily at midnight.

Parameters:

  • int $hour A number between 0 and 23 inclusive. 0 Means daily at 12:00 AM and 23 means at 11:00 PM. Default is 0.
  • int $minute A number between 0 and 59 inclusive. Represents the minute part of an hour. Default is 0.
Returns: booleanIf job time is set, the method will return true. If not set, the method will return false. It will not set only if the given time is not correct.
public function everyHour()Schedules a cron job to run every hour. The job will run at the start of the hour.public function everyMonthOn(int$dayNum, string$time)Schedules a cron job to run every month on specific day and time.

Parameters:

  • int $dayNum The number of the day. It can be any value between 1 and 31 inclusive.
  • string $time A day time string in the form 'hh:mm' in 24 hours mode.
Returns: booleanIf the time for the cron job is set, the method will return true. If not, it will return false.
public function exec(boolean$force)Execute the event which should run when it is time to execute the job. This method will be called automatically when cron URL is accessed. The method will check if it is time to execute the associated event or not. If it is the time, The event will be executed. If the job is forced to execute, the event that is associated with the job will be executed even if it is not the time to execute the job.

Parameters:

  • boolean $force If set to true, the job will be forced to execute even if it is not job time. Default is false.
Returns: booleanIf the event that is associated with the job is executed, the method will return true (Even if the job did not finish successfully). If it is not executed, the method will return false.
public abstract function execute()Execute the job. The code that will be in the body of that method is the code that will be get executed if it is time to run the job or the job is forced to executed. The developer must implement this method in a way it returns null or true if the job is executed successfully. If the implementation of the method throws an exception, the job will be considered as failed.Returns: boolean|nullIf the job successfully completed, the method should return null or true. If the job failed, the method should return false.public function getArgValue(string$name)Returns the value of a custom execution argument. The value of the argument can be supplied through the table that will appear in cron control panel. If the execution is performed through CLI, the value of the argument can be supplied to the job as arg-name="Arg Val".

Parameters:

  • string $name the name of execution argument.
Returns: string|nullIf the argument does exist on the job and its value is provided, the method will return its value. If it is not provided or it does not exist on the job, the method will return null.
public function getArgument(string$argName)Returns job argument as an object given its name.

Parameters:

  • string $argName The name of the argument.
Returns: JobArgument|nullIf an argument which has the given name was added to the job, the method will return it as an object. Other than that, the method will return null.
public function getArguments()Returns an array that holds execution arguments of the job. Returns: arrayAn array that holds objects of type 'JobArgument'.public function getCommand()Returns the command that was used to execute the job. Note that the command will be null if not executed from CLI environment.Returns: CronCommand|nullpublic function getDescription()Returns job description. Job description is a string which is used to describe what does the job do.Returns: stringJob description. Default return value is 'NO DESCRIPTION'.public function getExecArgs()Returns an associative array that contains the values of custom execution parameters. Returns: arrayAn associative array. The keys are attributes names and the values are the values which are given as input. If a value is not provided, it will be set to null.public function getExecArgsNames()Returns an array that contains the names of added custom execution attributes. Returns: arrayAn indexed array that contains all added custom execution attributes names.public function getExpression()Returns the cron expression which is associated with the job. Returns: stringThe cron expression which is associated with the job.public function getJobDetails()Returns an associative array which contains details about the timings at which the job will be executed. Returns: arrayThe array will have the following indices:
  • minutes: Contains sub arrays which has info about the minutes at which the job will be executed.
  • hours: Contains sub arrays which has info about the hours at which the job will be executed.
  • days-of-month: Contains sub arrays which has info about the days of month at which the job will be executed.
  • months: Contains sub arrays which has info about the months at which the job will be executed.
  • days-of-week: Contains sub arrays which has info about the days of week at which the job will be executed.
public function getJobName()Returns the name of the job. The name is used to make different jobs unique. Each job must have its own name. Also, the name of the job is used to force job execution. It can be supplied as a part of cron URL.Returns: stringThe name of the job. If no name is set, the function will return 'CRON-JOB'.public function hasArg(string$name)Checks if an argument with specific name belongs to the job or not.

Parameters:

  • string $name The name of the argument that will be checked.
Returns: booleanIf an argument with the given name already exist, the method will return true. False if not.
public function isDayOfMonth()Checks if current day of month in time is a day at which the job must be executed. Returns: booleanThe method will return true if the current day of month in time is a day at which the job must be executed.public function isDayOfWeek()Checks if current day of week in time is a day at which the job must be executed. Returns: booleanThe method will return true if the current day of week in time is a day at which the job must be executed.public function isForced()Checks if the job is forced to execute or not. Returns: booleanIf the job was forced to execute, the method will return true. Other than that, it will return false.public function isHour()Checks if current hour in time is an hour at which the job must be executed. Returns: booleanThe method will return true if the current hour in time is an hour at which the job must be executed.public function isMinute()Checks if current minute in time is a minute at which the job must be executed. Returns: booleanThe method will return true if the current minute in time is a minute at which the job must be executed.public function isMonth()Checks if current month in time is a month at which the job must be executed. Returns: booleanThe method will return true if the current month in time is a month at which the job must be executed.public function isSuccess()Returns true if the job was executed successfully. The value returned by this method will depends on the return value of the value which is returned by the method AbstractJob::execute(). If the method returned null or true, then it means the job was successfully executed. If it returns false, this means the job did not execute successfully. If it throws an exception, then the job is not successfully completed.Returns: booleanTrue if the job was executed successfully. False if not.public function isTime()Checks if its time to execute the job or not. Returns: booleanIf its time to execute the job, the method will return true. If not, it will return false.public abstract function onFail()Run some routines if the job is executed and failed to completed successfully. The status of failure or success depends on the implementation of the method AbstractJob::execute(). The developer can implement this method to take actions after the job is executed and failed to completed. It is optional to implement that method. The developer can leave the body of the method empty.public function onMonth(int|string$monthNameOrNum, int$dayNum, string$time)Schedules a job to run at specific day and time in a specific month.

Parameters:

  • int|string $monthNameOrNum Month number from 1 to 12 inclusive or 3 letters month name. Default is 'jan'.
  • int $dayNum The number of day in the month starting from 1 up to 31 inclusive. Default is 1.
  • string $time A time in the form 'hh:mm'. hh can have any value between 0 and 23 inclusive. mm can have any value between 0 and 59 inclusive. default is '00:00'.
Returns: booleanIf the time for the cron job is set, the method will return true. If not, it will return false.
public abstract function onSuccess()Run some routines if the job is executed and completed successfully. The status of failure or success depends on the implementation of the method AbstractJob::execute(). The developer can implement this method to perform actions after the job is executed and failed to completed. It is optional to implement that method. The developer can leave the body of the method empty.public function setCommand(CronCommand$command)Associate the job with the command that was used to execute the job.

Parameters:

public function setDescription(string$desc)Sets job description. Job description is a string which is used to describe what does the job do.

Parameters:

public function setJobName(string$name)Sets an optional name for the job. The name is used to make different jobs unique. Each job must have its own name. Also, the name of the job is used to force job execution. It can be supplied as a part of cron URL.

Parameters:

  • string $name The name of the job.
public function toJSON()public function weeklyOn(int$dayNameOrNum, string$time)Schedules a job to run weekly at specific week day and time.

Parameters:

  • int $dayNameOrNum A 3 letter day name (such as 'sun' or 'tue') or a day number from 0 to 6. 0 for sunday. Default is 0.
  • string $time A time in the form 'hh:mm'. hh can have any value between 0 and 23 inclusive. mm can have any value between 0 and 59 inclusive. default is '00:00'.
Returns: booleanIf the time for the cron job is set, the method will return true. If not, it will return false.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024