Skip to content

Unable to execute core:cron from crontab #187

Description

@MatteoBorgognoni

Hi I am trying to setup a crontab for executing the core:cron drush command.
I have trying to follow instructions at https://blog.docksal.io/running-scheduled-events-with-docksal-43fc69d7b29b without luck.

I have create a new crontab file under .docksal/services/cli
This is the content of the crontab:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/docker/.composer/vendor/bin
* * * * * drush --debug --root=/var/www/docroot core:cron -v > /tmp/drupal-cron.log 2>&1

(You can see I had to add to define the path variable as php wasn't even found.. It would have been good to find this mentioned in the instructions?)

This is the logged output:

Drush Launcher Version: 0.6.0
ROOT: /var/www/docroot
Drush Launcher Version: 0.6.0
ROOT: /var/www/docroot
DRUSH VERSION: 9
DRUPAL ROOT: /var/www/docroot
COMPOSER ROOT: /var/www
VENDOR ROOT: /var/www/vendor
 [preflight] Config paths: /var/www/vendor/drush/drush/drush.yml,/var/www/drush/drush.yml
 [preflight] Alias paths: /var/www/docroot/drush/sites,/var/www/drush/sites
 [preflight] Commandfile search paths: /var/www/vendor/drush/drush/src,/var/www/docroot/drush,/var/www/drush
 [debug] Bootstrap further to find core:cron [0.05 sec, 8.45 MB]
 [debug] Trying to bootstrap as far as we can [0.05 sec, 8.45 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.05 sec, 8.45 MB]
 [bootstrap] Change working directory to /var/www/docroot [0.05 sec, 8.45 MB]
 [bootstrap] Initialized Drupal 8.8.5 root directory at /var/www/docroot [0.05 sec, 8.58 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.06 sec, 8.94 MB]
 [bootstrap] Initialized Drupal site wwf.docksal at sites/default [0.06 sec, 9.11 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.06 sec, 9.11 MB]
 [debug] Add service modifier [0.06 sec, 9.32 MB]
 [bootstrap] Unable to connect to database. More information may be available by running `drush status`. This may occur when Drush is trying to bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic docs-aliases` for details. [0.06 sec, 9.33 MB]
 [debug] Bootstrap phase bootstrapDrupalDatabase() failed to validate; continuing at bootstrapDrupalConfiguration() [0.06 sec, 9.32 MB]
 [debug] Done with bootstrap max in Application::find(): trying to find core:cron again. [0.06 sec, 9.32 MB]

In Application.php line 239:
                                                                               
  [Symfony\Component\Console\Exception\CommandNotFoundException]               
  Command core:cron was not found. Drush was unable to query the database. As  
   a result, many commands are unavailable. Re-run your command with --debug   
  to see relevant log messages.                                                
                                                                               

Exception trace:
  at /var/www/vendor/drush/drush/src/Application.php:239
 Drush\Application->bootstrapAndFind() at /var/www/vendor/drush/drush/src/Application.php:192
 Drush\Application->find() at /var/www/vendor/symfony/console/Application.php:236
 Symfony\Component\Console\Application->doRun() at /var/www/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /var/www/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /var/www/vendor/drush/drush/src/Runtime/Runtime.php:49
 Drush\Runtime\Runtime->run() at /var/www/vendor/drush/drush/drush.php:72
 require() at /var/www/vendor/drush/drush/includes/preflight.inc:18
 drush_main() at phar:///usr/local/bin/drush/bin/drush.php:141
 require() at /usr/local/bin/drush:10

What am I missing???

This is my project config and variables:

version: "2.1"

services:
  cli:
    environment:
      # Make mysql environment variables from docksal.env available to the cli container.
      - MYSQL_DATABASE
      - MYSQL_PASSWORD
      - MYSQL_USER
      - DOCKSAL_ENVIRONMENT

  db:
    volumes:
      - ${PROJECT_ROOT}/db:/docker-entrypoint-initdb.d:ro
CLI_IMAGE='docksal/cli:2.10-php7.3'
DOCKSAL_STACK=default
DOCROOT=docroot

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions