I am using views data export module to generate a text file and that works perfectly. but instead of asking me to save it to my local computer.

What I want to do is save it directly on the server, I would like to run this is the background if possible as large amounts of data take time to generate. Ideally I would like to run this for each user in the background on cron run so I presume I will need to setup some batch job to run.


Well, I think you can set a cron job on server. You just need to add a drush command in crontab file. Drush command :

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

Views data export provides this drush command.

Edit :

  1. If you don't have drush installed on your server then you can take the idea from code of views_data_export.drush.inc.

Or :

  1. In simple way you can run the code following in hook_cron :

    $output = views_embed_view('ViewName', 'views_data_export_1'); file_unmanaged_save_data($Output , 'private://output.xls', FILE_EXISTS_REPLACE);

As per https://www.drupal.org/node/1875456#comment-7524421.

  • I don't have access to drush on the server so i cant do that sadly :( – Samp Jun 13 '15 at 16:22
  • @Jerry updated my answer. – Sumit Madan Jun 14 '15 at 5:40

Your Answer

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.