Arashi Interactive

Registered
Mar 14, 2021
2
0
1
Ontario, Canada
cPanel Access Level
Root Administrator
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.
 

Arashi Interactive

Registered
Mar 14, 2021
2
0
1
Ontario, Canada
cPanel Access Level
Root Administrator
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.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
9,881
1,539
313
cPanel Access Level
Root Administrator
Can you try this? This seems like a similar situation to what you're seeing: