{"id":9135,"date":"2026-05-31T20:16:58","date_gmt":"2026-05-31T18:16:58","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9135"},"modified":"2026-05-31T20:16:59","modified_gmt":"2026-05-31T18:16:59","slug":"cum-sa-executati-un-script-php-cu-parametri-utilizand-cron-in-mybox","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/","title":{"rendered":"Cum s\u0103 executa\u021bi un script PHP cu parametri utiliz\u00e2nd CRON \u00een mybox"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Why_parameters_are_not_supported_in_CRON\" >Why parameters are not supported in CRON<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Workaround_using_a_wrapper_PHP_file\" >Workaround: using a wrapper PHP file<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Step_1_Create_a_wrapper_file\" >Step 1: Create a wrapper file<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Step_2_Adjust_your_main_script\" >Step 2: Adjust your main script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Step_3_Add_the_wrapper_file_to_CRON\" >Step 3: Add the wrapper file to CRON<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Practical_implications\" >Practical implications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-run-a-php-script-with-parameters-using-cron-in-mybox\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_parameters_are_not_supported_in_CRON\"><\/span>Why parameters are not supported in CRON<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-4210788656\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To work around this limitation, parameters can be simulated inside PHP.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Workaround_using_a_wrapper_PHP_file\"><\/span>Workaround: using a wrapper PHP file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of calling the target script directly, you create a second PHP file that defines the parameters and then loads the main script.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Create_a_wrapper_file\"><\/span>Step 1: Create a wrapper file<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new PHP file, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cron-wrapper.php\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$_SERVER&#91;\"argv\"]&#91;1] = \"13\"; \/\/ first parameter example\n$_SERVER&#91;\"argv\"]&#91;2] = \"13\"; \/\/ second parameter example\n\n\/\/ add more parameters if needed\n\/\/ $_SERVER&#91;\"argv\"]&#91;3] = \"value\";\n\ninclude \"script.php\"; \/\/ target script\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This file simulates CLI-style arguments inside the PHP environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Adjust_your_main_script\"><\/span>Step 2: Adjust your main script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your main script (<code>script.php<\/code>) can now access these values using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$_SERVER&#91;\"argv\"]\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This allows the script to behave as if it was executed with parameters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Add_the_wrapper_file_to_CRON\"><\/span>Step 3: Add the wrapper file to CRON<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the mybox panel:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the CRON manager<\/li>\n\n\n\n<li>Create a new CRON job<\/li>\n\n\n\n<li>Select or specify the wrapper file (<code>cron-wrapper.php<\/code>)<\/li>\n\n\n\n<li>Set the desired execution schedule<\/li>\n\n\n\n<li>Save the task<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The CRON system will now execute the wrapper file, which passes parameters to the main script.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Practical_implications\"><\/span>Practical implications<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>allows simulated parameter passing in CRON<\/li>\n\n\n\n<li>keeps CRON configuration simple<\/li>\n\n\n\n<li>centralizes logic inside PHP files<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">However, parameters must be defined manually in the wrapper file, as CRON itself does not pass dynamic arguments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[13,39],"manual_kb_tag":[5934,5935,970,3459,3991,3992,5930,5931,5932,5933],"class_list":["post-9135","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-cron","manualknowledgebasecat-php-operations","manual_kb_tag-command-line-arguments","manual_kb_tag-job-manager","manual_kb_tag-cron-jobs","manual_kb_tag-php-scripts","manual_kb_tag-scheduled-tasks","manual_kb_tag-task-scheduler","manual_kb_tag-mybox-cron","manual_kb_tag-cron-wrapper","manual_kb_tag-wrapper-file","manual_kb_tag-passing-parameters"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9135\/revisions"}],"predecessor-version":[{"id":9136,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9135\/revisions\/9136"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=9135"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9135"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=9135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}