🚀
INEX Docs
  • 🚀INEX Team Documentation 💡🌍
  • INEX Blog
  • Contact Us
  • INEX SPA
    • Installation
      • Using Git
      • Manual Download
    • Getting Started
      • Running Locally
        • Using PHP's Built-in Server
        • Using Apache
      • Initial Configuration
      • Verify Installation
    • Ammar CLI
      • Extrenal Commands
        • list commands
          • list
          • list:routes
          • list:db
          • list:import
          • list:lang
          • list:cron
        • make commands
          • make:route
          • make:db
          • make:cache
          • make:sitemap
          • make:session
          • make:lang
          • make:layout
          • make:auth
        • get commands
          • get:cache
          • get:session
        • update commands
          • update:cache
        • delete commands
          • delete:route
          • delete:db
          • delete:cache
          • delete:import
          • delete:session
          • delete:lang
        • ask commands
          • ask:gemini
        • run/serve commands
          • run:db
          • serve
        • clear commands
          • clear:cache
          • clear:db
          • clear:db:tables
          • clear:routes
          • clear:start
          • clear:docs
          • clear:cron
        • install commands
          • install:import
      • Inline Commands
        • Route Management
        • Database Operations
        • Cache Operations
        • AI Assistance
        • Development Server
        • Library Manager
        • Session Manager
        • Language Manager
        • Layout Manager
        • Cronjob Management
    • Ahmed Template
      • {{}}
      • If Statement
      • ForEach
      • @getLang
      • @getEnv
      • Layout Feature
        • @getSection
        • @section and @endSection
        • @render
      • @include - Including Other Templates
      • @switch - Switch Case Statement
      • @for - Looping with a Fixed Range
      • @while - Looping Until a Condition is Met
      • @set - Assigning Variables
      • @dump - Debugging Variables
      • @dd - Debugging and Stopping Execution
      • @isset - Checking If a Variable Is Set
      • @empty - Checking If a Variable Is Empty
      • @php - Executing Raw PHP Code
      • @unless - Conditional Rendering for False Values
      • @break and @continue - Loop Control
      • String Case Conversion - @strtoupper, @strtolower, and @ucfirst
      • @number_format - Number Formatting
      • @date - Date Formatting
      • @runDB - Execute Database Migrations
      • @generateSitemap - Generate XML Sitemap
      • @checkRateLimit - Rate Limiting Requests
      • @validateCsrf - CSRF Protection
      • @define - Define Variables
      • {-- Comment Syntax --}
      • @escape - Escape Output
      • @substr - Extract a Substring
      • @jsonFile - Load JSON Data
      • @require - Include PHP Files
      • @do @whileCond - Do-While Loop
      • @setLang - Set Active Language
      • @var - Define and Use Variables
      • @phpCode - Execute Raw PHP Code
      • @postData - Send Data via HTTP POST
      • @toJson & @fromJson - JSON Conversion
      • @strlen & @trim - String Length and Trimming
      • @getData - Retrieve Data via HTTP GET
      • Cookie Management Directives
      • Session Management Directives
      • @useGemini - AI-Powered Assistance
      • Cache Management Directives
      • Section Management Directives
      • Other functions calling
    • Features
      • PWA Feature (Beta)
      • Cronjob Management
      • Built-in Motion Engine (Beta)
      • API Routes
      • Auth
        • How to use?
        • Start Use
          • Update Json/AuthParams.json
          • Create Auth file
            • Using ammar CLI
            • Using code
          • run .sql file
            • Using ammar CLI
            • Manually
        • Use
          • UserAuth::signIn
          • UserAuth::signUp
          • UserAuth::checkUser
          • UserAuth::logout
      • Webhook
      • Notification
      • Security
      • Logger
      • Firewall
      • Validation
        • isEmail
        • isTextLength
        • isMinTextLength
        • isSubDomain
        • isSubDir
        • isDomain
        • isEndWith
        • isStartWith
        • isNumber
        • isBool
      • Ahmed Template
      • Cookie Management
        • JavaScript (JS)
        • PHP
      • Session Management
      • Enable Multi Language
      • Submit Data without redirect
      • Layout Feature
      • Run DB Folder SQL files
      • SiteMap Generator
      • Use Rate Limiter
      • Application Title System
      • Use Gemini
      • Cache system
        • Create a new Cache
        • Get a Cache Value
        • Update Cache Value
        • Delete Cache
      • Run MySQL Commands
      • Automaticly CSRF Security
      • Get Website URL Without getEnvValue function
      • Use Bootstrap
      • Database Connection
      • Submit Data without Page Refresh
        • Basic Form Implementation
        • Server-Side Handling
        • Important Notes
      • Check Request Type
      • Create Dynamic Routes
      • Client-Side Navigation (Redirect without Refresh)
        • Basic Redirection
        • Dynamic Route Navigation
        • Common Usage Patterns
        • Important Notes
      • Get Values From .env file
      • Get Data from Twice Slash
    • Libraries
      • Download Library
        • 1- Using ammar CLI (recommended)
          • Example 1
        • 2- Manually Download
          • Example 1
      • Use library
        • Example 1
    • Notes
      • Use ""
      • Delete Docs files
      • Should name .ahmed.php
      • Don't delete JS & errors folder
      • Don't use these names in files
      • JavaScript Execution Conflicts
        • Problems this causes
        • Best practices
      • Production Database Checks
      • Route Type Restrictions
      • Autoloading Framework Components
      • Framework Core Isolation
      • Additional Notes
      • Add .git suffix
    • Best Practices
      • Code Organization
      • Security
      • Performance
      • Development
      • Database
      • Maintenance
    • Apache License
    • Security Policy
    • Repository
    • Star History
    • How to create a new library?
      • Create a folder
      • Create a library files
        • Create a file
          • Example 1: hi.php
          • Example 2: useFramework.php
      • Create init.php file
      • Create README.md file
      • Congratulations!!!
      • Upload to Github
      • Notes
        • Class Name like to file name
        • Create a folder
        • Don't match INEX SPA
  • Changelog
    • v5.2
    • v5.0
    • v5
    • v4.9.3
    • v4.9.1
    • v4.9-beta
    • v4.8.5-beta
    • v4.8-beta
    • v4.4-beta.10
    • v4.1-beta.9
    • v3.7.6.5.8.1-beta.8
    • v3.7.6.5.8.0-beta.7
    • v3.5.62.78-beta.6
    • v3.40.73-beta.5
    • v3.36.69-beta.4
    • v2.12.39-beta.3
    • v1.1.3-beta.2
    • v1.0-beta.1
Powered by GitBook
On this page
Edit on GitHub
  1. INEX SPA
  2. Features

Cronjob Management

This application includes a cronjob management system to schedule and run background tasks. Tasks are defined as PHP classes and can be managed using the ammar CLI.

Cron Runner

The core script for executing cron tasks is core/cron/cron_runner.php. This script is designed to be called by your system's cron daemon (e.g., crontab).

Usage:

/usr/bin/php /path/to/your/project/core/cron/cron_runner.php <TaskName> >> /path/to/your/project/core/logs/cron.log 2>&1
  • Replace /usr/bin/php with the actual path to your PHP interpreter if different.

  • Replace /path/to/your/project/ with the absolute path to your application's root directory.

  • <TaskName> is the name of the cron task class you want to run (e.g., ExampleTask).

  • It's recommended to redirect output to the core/logs/cron.log file for monitoring.

ammar CLI Commands for Cronjobs

The ammar CLI tool provides several commands to help manage your cron tasks:

1. list:cron

Lists all available cron tasks. These are the .php files found in the core/cron/tasks/ directory.

Usage:

php ammar list:cron

2. make:cron <TaskName>

Creates a new cron task file in core/cron/tasks/. The <TaskName> should be a valid PHP class name (e.g., MyDailyReport).

Usage:

php ammar make:cron MyDailyReport

This will generate core/cron/tasks/MyDailyReport.php with a template class structure. You'll need to edit this file to implement the task's logic within the handle() method.

3. run:cron <TaskName>

Manually triggers a specific cron task. This is useful for testing your cron tasks without waiting for the scheduled time.

Usage:

php ammar run:cron <TaskName>

Example:

php ammar run:cron ExampleTask

4. delete:cron <TaskName>

Deletes a specific cron task file from core/cron/tasks/. You will be prompted for confirmation.

Usage:

php ammar delete:cron <TaskName>

5. clear:cron

Deletes ALL cron task files from core/cron/tasks/. This is a destructive operation and will require double confirmation.

Usage:

php ammar clear:cron

Creating a New Cron Task

  1. Use the make:cron command to generate the task file:

    php ammar make:cron YourNewTaskName
  2. Open the generated file core/cron/tasks/YourNewTaskName.php.

  3. Implement your task's logic within the handle() method of the class. You can use any PHP code, access your application's models, services, or other functions as needed. Ensure necessary classes and functions are loaded, potentially by referencing how core/cron/cron_runner.php or index.php load dependencies. The cron_runner.php should provide a basic environment, but complex tasks might need to ensure their specific dependencies are met.

  4. Test your task using php ammar run:cron YourNewTaskName.

  5. Once ready, schedule it via your system's crontab by pointing to core/cron/cron_runner.php YourNewTaskName.

PreviousPWA Feature (Beta)NextBuilt-in Motion Engine (Beta)

Last updated 7 days ago