I am trying to set up cron jobs in cpanel using a hosted Godaddy account.
I put in the following script: /usr/local/bin/php -f /home/my username/public_html/mautic/app/console mautic:campaign:trigger -e prod
I get the following response: Script in progress. Use -f or --force to force execution.
I let the cron job run for about an hour and I get the same response.
The scripts for the 2 other cron jobs seem to work fine.
I’m on GoDaddy too and am having a heck of a time trying to get the cron job to run - could you tell me what script you ended up using that worked?
I am trying to set up cron jobs in cpanel using a hosted Godaddy account.
I put in the following script: /usr/local/bin/php -f /home/my username/public_html/mautic/app/console mautic:campaign:trigger -e prod
I get the following response: Script in progress. Use -f or --force to force execution.
I let the cron job run for about an hour and I get the same response.
The scripts for the 2 other cron jobs seem to work fine.
I think I have resolved the cron jobs problem.
How did you solve this? I’m running into the same thing.
@menolo , for cron jobs cpanel issue there’s another way to fix it. Follow these steps:
1- Login your cPanel and open File Manager.
2- Create new file into Mautic’s folder named cronjob.php (or any one of your choice).
3- Copy this script and paste into cronjob.php. Then replace ILoveMAUTIC by any of your choice. Save and close.
<?php
if (!isset($_GET['ILoveMAUTIC'])) {
echo 'The secret phrase is wrong.';
die;
}
$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$allowedTasks = array(
'cache:clear',
'mautic:leadlists:update',
'mautic:campaigns:update',
'mautic:campaigns:trigger',
'mautic:email:process',
'mautic:fetch:email',
'doctrine:migrations:migrate',
'doctrine:schema:update --dump-sql',
'doctrine:schema:update --force'
);
if (!isset($_GET['task'])) {
echo 'Specify what task to run. You can run these:';
foreach ($allowedTasks as $task) {
$href = $link . '&task=' . urlencode($task);
echo '<br><a href="' . $href . '">' . $href . '</a>';
}
echo '<br><a href="https://www.mautic.org/docs/setup/index.html">Read more</a>';
echo '<br><b style="color:red">Please, backup your database before executing the doctrine commands!</b>';
die;
}
$task = urldecode($_GET['task']);
if (!in_array($task, $allowedTasks)) {
echo 'Task ' . $task . ' is not allowed.';
die;
}
$fullCommand = explode(' ', $task);
$command = $fullCommand[0];
$argsCount = count($fullCommand) - 1;
$args = array('console', $command);
if ($argsCount) {
for ($i = 1; $i <= $argsCount; $i++) {
$args[] = $fullCommand[$i];
}
}
require_once __DIR__.'/app/bootstrap.php.cache';
require_once __DIR__.'/app/AppKernel.php';
use SymfonyBundleFrameworkBundleConsoleApplication;
use SymfonyComponentConsoleInputArgvInput;
use SymfonyComponentConsoleOutputBufferedOutput;
defined('IN_MAUTIC_CONSOLE') or define('IN_MAUTIC_CONSOLE', 1);
try {
$input = new ArgvInput($args);
$output = new BufferedOutput();
$kernel = new AppKernel('prod', false);
$app = new Application($kernel);
$app->setAutoExit(false);
$result = $app->run($input, $output);
echo "<pre>n".$output->fetch().'</pre>';
} catch (Exception $exception) {
echo $exception->getMessage();
}
4- Type into browser: domain.com/mautic/cronjob.php?ILoveMAUTIC replacing whatever needed. Assuming /mautic/ installation folder. It will be displayed many options to click. It’s a manual cron job for while. Keep this tab open.
5- Sign up here: https://cron-job.org/ .It’s free up to 60 cron jobs but you’ll need upto 4 cron jobs.
6- Include new URLs from tab at step 4.
domain.com/mautic/cronjob.php?&task=mautic%3Aleadlists%3Aupdate
domain.com/mautic/cronjob.php?&task=mautic<ampaigns%3Aupdate
domain.com/mautic/cronjob.php?&task=mautic<ampaigns%3Atrigger
domain.com/mautic/cronjob.php?&task=mautic>mail%3Aprocess - This one just for using queue email.
I’ve tested and it works fine!
Thx to @escopecz and @ninjoan
There is another easy-to-use cron job service that may help: https://www.easycron.com.
@Sokoban I had problems with your script when multiple cronjobs were running at the same time. Here is my solution:
https://www.mautic.org/community/index.php/4395-why-17-minutes-delay
I m in a cpanel without shell access
Your cronjob script Saved my day. I was able to see the error and fix it. Thank you @Sokoban