1

I'm working on a drupal 7 site and my client would like to have a certain view export as a CSV once a day into a folder. My initial thought was to tie this functionality to our cron schedule, but I'm running into a wall. How can I add functionality to cron? And more specifically, how could I get a specific view to export as a CSV during cron?

Thanks!

New contributor
dwinste is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • If my solution (below) helps you to resolve your issue, please accept my answer by clicking the green check mark; otherwise it will always be marked as an unanswered question, and it will clutter the forum. Fight Zombie Questions! – hotwebmatter 2 days ago
2

You might want to look at the Views Data Export contrib module: https://www.drupal.org/project/views_data_export

This module exposes a drush command that can execute the view and save its results to a file.

drush views-data-export [view-name] [display-id] [output-file]

Since you can call this command via drush from the shell, you should also be able to add the drush command to the operating system crontab (not Drupal cron) so that it executes on a schedule:

https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/

Your Answer

dwinste is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.