In mybox, the CRON job manager does not support passing parameters directly to PHP scripts. This means you cannot define command-line arguments in a standard CRON entry.
To achieve the same result, you can use a simple workaround by creating an intermediate PHP file that sets parameters before including the target script.
Table of Contents
Why parameters are not supported in CRON
CRON tasks execute predefined commands at scheduled intervals. In this environment, the CRON manager does not interpret additional script arguments, which limits direct parameter passing to PHP scripts.
To work around this limitation, parameters can be simulated inside PHP.
Workaround: using a wrapper PHP file
Instead of calling the target script directly, you create a second PHP file that defines the parameters and then loads the main script.
Step 1: Create a wrapper file
Create a new PHP file, for example:
cron-wrapper.php
Add the following content:
<?php
$_SERVER["argv"][1] = "13"; // first parameter example
$_SERVER["argv"][2] = "13"; // second parameter example
// add more parameters if needed
// $_SERVER["argv"][3] = "value";
include "script.php"; // target script
This file simulates CLI-style arguments inside the PHP environment.
Step 2: Adjust your main script
Your main script (script.php) can now access these values using:
$_SERVER["argv"]
This allows the script to behave as if it was executed with parameters.
Step 3: Add the wrapper file to CRON
In the mybox panel:
- Open the CRON manager
- Create a new CRON job
- Select or specify the wrapper file (
cron-wrapper.php) - Set the desired execution schedule
- Save the task
The CRON system will now execute the wrapper file, which passes parameters to the main script.
Practical implications
This approach:
- allows simulated parameter passing in CRON
- keeps CRON configuration simple
- centralizes logic inside PHP files
However, parameters must be defined manually in the wrapper file, as CRON itself does not pass dynamic arguments.
Summary
Since CRON in mybox does not support direct parameter passing to PHP scripts, a wrapper PHP file can be used to define parameters and include the main script. This allows controlled execution of scripts with custom values.