control-cron.sh Script Documentation
This document describes the functionality and usage of the control-cron.sh script found in the cruiseappy/scripts folder.
Purpose
Automates the processing and execution of scheduled jobs defined as WordPress options, leveraging WP-CLI and jq for data extraction and manipulation.
Usage
./control-cron.sh
Description
- Loads helper functions from a sibling
functions.shscript. - Retrieves all WordPress options matching
options_jobs_*as JSON using WP-CLI. - Iterates through each job, extracting scheduling and execution details.
- Handles PHP serialized option values by unserializing and converting them to JSON.
- Processes scheduling parameters:
- *_day: Checks if the current day matches any in the job's schedule.
- *_hour: Checks if the current hour matches any in the job's schedule.
- *_location: Determines the execution endpoint (theme, plugin, or remote).
- *_script: Specifies the script to execute.
- Combines endpoint and script to form the full execution path or URL.
- Executes the endpoint if both the current hour and day match the job's schedule.
Environment Variables
wordpress_path: Path to the WordPress installation.ca_theme: Name of the active theme (used when location is "theme").
Dependencies
- bash
- WP-CLI
- jq
- PHP (for unserializing PHP arrays)
Notes
- Intended for use by developers or system administrators familiar with WordPress and server scripting.
- Place this script in the appropriate plugin/scripts directory.
- Ensure
functions.shexists in the same directory. - Run the script with appropriate permissions and environment variables set.
For further details, refer to the comments in the script or contact the development team.