If you’re running your server on MAMP, you’ve likely used this solution to get WP CLI to work on your system. This will append the output of your command to the file /path/to/your/log.txt. If you’d like to generate a log every time your migration runs, you can modify your crontab to redirect the output of the command to a file like so: 0 2 * * * /usr/local/bin/wp migratedb profile 8 -path=/var/www/wordpress/ > /path/to/your/log.txt 2>&1 You can check that your Cron job was added successfully using the following command: $ crontab -lĬheck here for more information and examples of Crontab syntax. I want my migration to be performed at 2am every day so I’ll add the following line to my Crontab file: 0 2 * * * /usr/local/bin/wp migratedb profile 8 -path=/var/www/wordpress/ Open your Crontab file for editing: $ crontab -e Now you can set up your system’s Cron to run your migration command. You should replace /usr/local/bin/wp with the absolute path to the wp command on your system and /var/www/wordpress with the absolute path to your wordpress install. With those two amendments, the Cron-safe command should look something like this: $ /usr/local/bin/wp migratedb profile 8 -path=/var/www/wordpress/ Cron won’t be running the command from your WordPress install’s directory, so you’ll want to use the WP CLI global parameter -path to point to the root of your WordPress install.Even if the wp command is in your user’s $PATH it may not be in the context that Cron runs in, so you’ll want to use the absolute path to wp.Since we’ll be running this command via the system’s cron we’ll want to modify the command in two ways Run the command first to make sure it’s doing exactly what you want: $ wp migratedb profile 8 In this example, I’ve set up a profile that will pull the database and media files from my live server down to the development server on my local machine and have noted that it’s ID is 8. The first thing you’ll want to do is work out the command you’d like to schedule, or set up a migration profile in WP Migrate DB Pro’s Migration tab in your WordPress admin.
#CRON JOB USING MAMP PRO PRO#
While WP Migrate DB Pro doesn’t offer a built-in method for scheduling migrations, this is something that can be easily and reliably achieved using your system’s Cron and the WP Migrate DB Pro CLI Addon.