Magento: Possible to run export profile from shell ssh

Magento: Possible to run export profile from shell ssh

July 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Possible to run export profile from shell ssh

Solving Magento Export Stuck Issues: Running Profiles via SSH

Exporting large product catalogs from Magento can often lead to mysterious hangs or errors during the process. If you’re stuck in a loop with the “Warning: Please do not close the window” message, you’re not alone. Let me guide you through a practical solution for running dataflow profiles directly from an SSH shell.

Understanding the Magento Export Process

Before we dive into the command-line interface, it’s important to understand what happens behind the scenes when you initiate an export profile. Magento uses its cron process to manage batch operations like exports and reindexing. This is especially crucial when dealing with massive datasets that exceed your server’s available memory.

The Challenge: Running Export Profiles from SSH

By default, Magento doesn’t provide a straightforward way to start an export profile directly via SSH. The export interface in the admin panel is designed for manual interaction and doesn’t expose an API or command-line interface for this purpose.

However, with some creative use of existing features and a bit of customization, we can achieve this goal.

A Workaround: Using PHP Shell Scripts

Magento allows you to run PHP scripts directly from the file system. We can leverage this functionality to build a simple shell script that triggers our desired dataflow profile execution.

Here’s how to create an SSH-friendly export script:

  1. Create a new PHP file (e.g., run_profile.php) in your Magento root directory.
  2. Open this file and add the following code:
<?php
require_once 'app/Mage.php';
Mage::init();
Mage::register('isSecureArea', true);
$profileId = 1; // Replace with your profile ID
Mage::getModel('dataflow/profile')->setProfile($profileId)->importData();

Replace 1 in the $profileId variable with your actual dataflow profile ID.

  1. Save the file and give it executable permissions using SSH:
chmod +x run_profile.php

Running Your Export Script via SSH

Now that we have our script ready, let’s run it from an SSH session:

  1. Connect to your server using SSH.
  2. Navigate to your Magento root directory.
  3. Run the command:
php run_profile.php

This will start the export process for the specified profile ID in the background.

Best Practices and Troubleshooting

  • To monitor progress, you can check the dataflow_batch table in your database.
  • If the export takes a long time or still doesn’t complete, consider increasing memory limits and adjusting cron settings as needed. Read more about memory management in our article on Optimizing Magento Performance.
  • For a more sophisticated approach, you can set up a custom script that loops through batches or handles errors, but this goes beyond the scope of a simple SSH solution.

Conclusion

While Magento doesn’t provide an out-of-the-box way to run dataflow profiles via SSH, we’ve demonstrated how to create a workaround using PHP scripts. This method allows for more efficient management of large-scale exports, especially when you need to automate the process or trigger it remotely.

Remember to always test in a development environment before implementing changes on your live site and keep an eye on resource usage during heavy export operations. By following these steps, you should be able to handle those pesky stuck exports with ease.

Catalog Indexing API Admin

Our network