From within a custom JSON migration module I'm trying to run the following

function migrate_source_example_json_cron() {
  /usr/local/bin/drush --root=/code --uri=example.com migrate-import --all --update
}

With the //Do some stuff line in there its showing up correctly in Ultimate Cron.

Obviously, I'm not using example.com :).

Enabling the module immediately fails when it gets to the first /.

Parse error: syntax error, unexpected '/' in /code/modules/migrate_source_example/modules/migrate_source_example_json/migrate_source_example_json.module on line 32 Call Stack: 0.0030 254616 1. {main}() /code/index.php:0 0.0045 552560 2. Drupal\Core\DrupalKernel->handle() /code/index.php:19 0.0129 1669752 3. Stack\StackedHttpKernel->handle() /code/core/lib/Drupal/Core/DrupalKernel.php:652 0.0129 1669864 4. Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23 0.0129 1670256 5. Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() /code/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50 0.0129 1670688 6. Drupal\page_cache\StackMiddleware\PageCache->handle() /code/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47 0.0134 1681640 7. Drupal\page_cache\StackMiddleware\PageCache->pass() /code/core/modules/page_cache/src/StackMiddleware/PageCache.php:78 0.0134 1681720 8. Drupal\Core\StackMiddleware\KernelPreHandle->handle() /code/core/modules/page_cache/src/StackMiddleware/PageCache.php:99 0.0134 1681952 9. Drupal\Core\DrupalKernel->preHandle() /code/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:45 0.0147 1795504 10. Drupal\Core\Extension\ModuleHandler->loadAll() /code/core/lib/Drupal/Core/DrupalKernel.php:544 0.0154 1807416 11. Drupal\Core\Extension\ModuleHandler->load() /code/core/lib/Drupal/Core/Extension/ModuleHandler.php:140 0.0154 1807416 12. Drupal\Core\Extension\Extension->load() /code/core/lib/Drupal/Core/Extension/ModuleHandler.php:127

Basically, I'm trying to access drush locally, set the root of the drupal site, and run the command migrate-import --all --update once an hour. All of the info has been taken directly from the drush status so it should all resolve locally.

Thanks for any help you can provide.

Best,
Shawn

Comments

shawnmatthews created an issue. See original summary.

Berdir’s picture

Status: Active » Fixed

That is not PHP what you have there, this can not work.

I suggest you ask on Drupal Answers, IRC or some other support ressource on either setting up a standone system cron job or run the migration with PHP.

shawnmatthews’s picture

Well that explains a lot. I thought it accepted basic CRONTAB syntax which obviously now looking at it makes zero sense.

Thanks!

Best,
Shawn

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.