Hot answers tagged

50

You can try drush core-cron $ drush help core-cron Run all cron hooks in all active modules for specified site. Aliases: cron


25

It's now in the semaphore table with the key name "cron". This can be removed via a drush sqlq "DELETE FROM semaphore WHERE name = 'cron';" command. Or, if you can execute PHP in Drupal bootstrapped environment, you can run the line: \Drupal::lock()->release('cron');


21

You can do drush php-eval 'my_module_cron();' and it should run.


21

You can use drush core-cron or just drush cron If you wish to use drush to run cron from a crontab, it's best to run cron as the web server user, and supply it with additional arguments to make up the lack of a terminal and supply environment variables. The drush documentation explains it best either at docs/cron.html or run drush topic docs-cron. ...


20

When Drupal runs cron tasks, it automatically handles any cron queue defined from modules, in drupal_cron_run(); first hook_cron() implementations are invoked, and then the cron queues are emptied. Inmplementing hook_cronapi(), you can add an entry for another function handling the cron queue of your module. function mymodule_cronapi($op, $job = NULL) { $...


19

Summary The error message you are seeing would happen if the following two conditions are met: You cron jobs do not finish (error) or take more than 4 minutes to finish ; You invoke cron more often than every 4 minutes (According to your crontab setting, not the setting in Drupal) This error message is therefore a symptom of a cron tasks that is either ...


19

A UNIX timestamp of the last cron run can be fetched with: variable_get('cron_last'); If you need to, you can easily manipulate a UNIX timestamp with PHP's date function.


13

Drupal 7 incorporated in its modules the code that were in Poormanscron, whose purpose is exactly to run Drupal cron tasks on a site where it is not possible to set cron tasks, when a user visits your site, and every X hours (as set in the page you saw). If you want to avoid that behavior, you just need to set "Run cron every" to "Never"; contrary to what ...


13

You can look at the example code shown in the documentation from hook_cron_queue_info(), which still needs an explanation on how it is used. function hook_cron_queue_info() { $queues['aggregator_feeds'] = array( 'worker callback' => 'aggregator_refresh', 'time' => 60, ); return $queues; } The code show is actually the implementation of ...


12

The cron semaphore is probably locked. You could try calling drupal_cron_cleanup() from anywhere in your code (that doesn't happen to be invoked by cron) and that should unlock your cron semaphore variable. If you have drush configured in Drupal 6 you could also try: $ drush vdel -y cron_semaphore


10

You can get really fine-grained control over your cron runs with these modules: Elyisa cron Elysia Cron extends Drupal standard cron, allowing a fine grain control over each task and several ways to add custom cron jobs to your site. Ultimate Cron The Ultimate Cron handling for Drupal. Runs cron jobs individually in parallel using configurable ...


10

I've been digging through this code, and Feeds does not use Background Process. It uses Job Scheduler From FeedsSource.inc: /** * Background job helper. Starts a background job using Job Scheduler. * * Execute the first batch chunk of a background job on the current page load, * moves the rest of the job processing to a cron powered ...


9

You should start by reading the Drupal handbook pages about cron to get background and commands to run. If you have shell/SSH access to the (Linux) server, you can run use run crontab -u www-data -e to edit the cron table for the web user. You should be able to use the details in the above link to set up proper cron runs as often as you'd like. If you're on ...


9

update elysia_cron set running = 0 where name = '[THE NAME IF YOUR CRON JOB]'; Actual sql query based on Mika A answer above


8

Is it overkill to run drupal cron so frequently ? The answer to that is...it depends. If your cron task needs to run every 10 minutes, then no, it's not overkill. If it doesn't, then it is overkill. What you probably need is something like Elysia Cron, which lets you schedule cron jobs for specific modules on a an individual basis. That way you can run your ...


8

Unless I'm mistaken. Poormans cron significantly impacts page load performance when cron runs. I only use it on sites I'm quickly working with locally and have no intention of working on in the near future again. Using crontab to run cron completely removes the detrimental performance of using poormans cron, apart from the subsequent page load having to re-...


8

Try out the Ultimate Cron module. Runs cron jobs individually in parallel using configurable rules, pool management and load balancing. Multiple rules per cron job. Configuration per job (enable/disable, rules, etc.) There is also the Elysia Cron module. Elysia Cron extends Drupal standard cron, allowing a fine grain control over each task and several ...


8

Or simple use drush ev 'var_dump(module_implements("cron"))' For list the cron job that exists.


8

In Drupal 7: To determine if the current page request is a request for cron: in other words, "is my code being called during cron"? If you're running cron through cron.php, this is probably sufficient: return strpos($_SERVER['REQUEST_URI'], 'cron.php') !== 0; A more reliable way to determine a cron would be through introspection (e.g. debug_backtrace()), ...


8

I have also encountered this kind of issue that running EntityFieldQuery does not work sometimes in the cron job. It turns out that EntityFieldQuery will run access check. Cron job is run as anonymous user role and it cannot access to order_status node. To work around this issue you can add tag DANGEROUS_ACCESS_CHECK_OPT_OUT to bypass node access. Here ...


8

If you take a look at system_cron(), you will see $cache_tables = array_merge(module_invoke_all('flush_caches'), $core); foreach ($cache_tables as $table) { cache_clear_all(NULL, $table); } Reading the docs for cache_clear_all($cid, $bin): $cid: If set, the cache ID or an array of cache IDs. Otherwise, all cache entries that can expire are deleted. ...


8

As often as you like :) By default you can configure it on: /admin/config/system/cron (This will be executed on someone's page load, so it is importan to know that if nobody visits your site this will not be executed). This is known as poormanscron (Drupal 6). Calling with a internal/external cron script (wget for example) to yoursite.com/cron.php This is ...


8

You should configure a separate cron entry for CiviCRM on your server. CiviCRM's Managing Scheduled Jobs is the reference documentation here. Best practice is to run your CiviCRM cron separately. Many CiviCRM tasks (eg delivering large email runs) are not suited to Drupal's typical cron schedule. Running CiviCRM cron from Drupal means that an issue with ...


8

You don't. Batch API is to do long-running processing with user-interaction. For cron, you either use queue API or you just process for N seconds/things in your hook_cron() implementation, and in both cases, cron will be calling you repeatedly until it is eventually done. If you want to process as fast as possible then either use a different queue ...


8

Instead of using Cron API you could provide your own custom Drush command and implement Batch API there. And then execute this Drush command using your server's crontab. Following comes a sample command that implements a batch. Inside module_name.drush.inc put: function module_name_drush_command() { $items = array(); $items['migrate-batch-list'] = ...


7

The problem is not drupal_goto() but your usage of it in a node. THere is a long standing issue in Drupal core to deal with this but I honestly think doing this is just wrong. Instead of putting it in a node, you should create a custom module and put it in a page callback. See What are the downsides of using 'custom' PHP code in blocks, nodes, views-args, ...


7

I would check the implementation of hook_cron() in the Examples module. The exact implementation is here, it's pretty straightforward! Basically, you're setting the next execution time (in the example code as cron_example_next_execution) of your cron run as the very last step in your hook_cron() implementation, and then checking it as the very first thing. ...


7

You could use drush core-cron command that would run the cron . For more detailing about the commands that drush provides us is there on https://drushcommands.com/


7

As you said "the cron works only when I run it manually in the admin section (Elysia cron configuration), but I need it to be runing every some specific periode !", it tells your codes are working fine. By default Drupal cron runs when site is accessed and it evaluates when was the last time cron ran, so if the prescribed time is passed cron will run again, ...


7

You should use the function dd() to log something during cron. Here is the doc: https://api.drupal.org/api/devel/devel.module/function/dd/7 It will log the output to a file, which later you can investigate. I think you must have private file path set. you could use something like this, But be careful about XSS! $export = var_export($var, TRUE) // TRUE ...


Only top voted, non community-wiki answers of a minimum length are eligible