Hallelujah!
Here is the answer.
Stackoverflow is a huge help for me, I have greatly benefited from the responses of the participants, today I am very happy to participate in the community with this answer, and I hope that this will help developers like me who have no choice to work with Joomla.
So here is how to build a cron with Joomla.
, cron, unix cron. php. , Joomla.
/Cli
<?php
const _JEXEC = 1;
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once JPATH_BASE . '/includes/framework.php';
class myCron extends JApplicationCli
{
public function doExecute()
{
require_once JPATH_BASE.'/administrator/components/com_mycom/helpers/XMLImporter.php';
echo "CRON TASK START ";
echo "\n";
$instance = PropertyXMLImporter::instance();
$instance->execute_import();
echo "CRON TASK END ";
echo "\n";
}
}
JApplicationCli::getInstance('myCron')->execute();
.
> crontab -e
vi, ZZ : q! , , ( Mac)
> export EDITOR=nano
> crontab -e
:
*/1 * * * * php /Applications/MAMP/htdocs/YOURPROJECT/PATH-TO-THE-CRON/cronTask.php
, ,
> crontab -l
*/1 * * * * - Cron, , : https://en.wikipedia.org/wiki/Cron
*/1, . , , . , 3 . 0 3 * * *
1: cron /1! (*/1 * * * *) (1 * * * *).
2: cron localhost " MySQL".
public $ host = '127.0.0.1';
public $ host = 'localhost'; , ** ! ...
3: , , , cron /cli. , , cron.
, - !