WP CLI Cron
I'm trying to setup a wp cli cron within cPanel with little success. WP cli is installed on the server and accessible by all users when logged in via ssh; saved in the recommended /usr/bin/local/wp. If I were to run the following command within cPanel Cron Jobs: wp db export I'm met with: "wp: command not found".
I've tried using:
/usr/local/php wp db export
/usr/local/php /usr/local/bin/wp db export
Neither seem to work thus far. I've been Google'ing for the last few hours trying to find a solution with no luck. I'm sure there's something very simple I've overlooked; any thoughts?
Thanks in advance.
-
Hey there! You mention /usr/bin/local/wp - is that the renamed wp-cli.phar file? If so, I would expect that to work properly as users should all be able to read that path on the system. More details on that process can be found here: WP CLI: Install and Manage WordPress" on the Command Line | cPanel Blog 0 -
Hi there, Yes, following the instructions from here: Command line interface for WordPress | WP-CLI From the command line (either through Terminal in WHM or PuTTY) all users can use the wp cli command. It's only when trying to use that in a cPanel Cron that I get errors saying that wp cannot be found. As I've been searching for a solution for about a week now to no avail, I finally used a secondary server I have to setup a cron that uses SSH to log into WHM/cPanel as the user, run the needed wp cli commands, then log out. I do find it odd that this can't be done via the built in cPanel cron manager. I'm able to run php scripts in cron fine by prepending the file/command with /usr/local/bin/php - so why wouldn't it also work using /usr/local/bin/wp? I'd assume the path would be setup so that all users can run commands found within /usr/local/bin. 0
Please sign in to leave a comment.
Comments
3 comments