• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

wp-cli as cron-job

godfather21

Basic Pleskian
Server operating system version
AlmaLinux 8.10
Plesk version and microupdate number
18.0.63
Hello,

i am using wp all import and i want to replace the cron-jobs to run via cli but when i go to create a new cron-job via plesk panel with the following command as an example

plesk ext wp-toolkit --wp-cli -instance-id 3 -- plugin list
i get as response /bin/sh: plesk: command not found.

I searched and found in another thread an example like this /usr/sbin/plesk ext wp-toolkit -wp-cli -instance-id 3 -- core info but this does not run also.

Can anyone suggest a solution for this?
 
The /bin/sh: plesk: command not found error indicates that you are trying to run Plesk's CLI without being logged in as the root user. If you have a sudoer user, you will still have to elevate the session to root using the command sudo su before being able to run such commands.
 
The /bin/sh: plesk: command not found error indicates that you are trying to run Plesk's CLI without being logged in as the root user. If you have a sudoer user, you will still have to elevate the session to root using the command sudo su before being able to run such commands.
Thank you for your recommendation but even i added the command sudo su plesk ext wp-toolkit --wp-cli -instance-id 6 -- -- wp all-import run 16 --skip-plugins=false i still receive the same response
 

Attachments

  • Screen Capture 761 - Schedule a Task - Plesk Obsidian 18.0.63 - ws4.vendoadv.gr.jpg
    Screen Capture 761 - Schedule a Task - Plesk Obsidian 18.0.63 - ws4.vendoadv.gr.jpg
    130.2 KB · Views: 9
@godfather21 I am assuming that the SSH user you are trying to run the command with is not added to wheel group and doesn't have sudo privileges. Note that if you take that path, you will also need to enable NOPASSWD in order for that to work, which might be a security risk.

It might be better to consider configuring the task from Tools & Settings > Scheduled tasks in order to directly execute the command with the root user.
 
@godfather21 I am assuming that the SSH user you are trying to run the command with is not added to wheel group and doesn't have sudo privileges. Note that if you take that path, you will also need to enable NOPASSWD in order for that to work, which might be a security risk.

It might be better to consider configuring the task from Tools & Settings > Scheduled tasks in order to directly execute the command with the root user.

I tried also with the scheduled tasks as root in plesk panel admin i get that it's completed but when i try via ssh i get the following response

PHP Warning: Undefined array key 0; File: /usr/local/psa/admin/plib/modules/wp-toolkit/library/Capability/WpCli/LocalPleskLinux.php, Line: 17

PHP Warning: Undefined array key 0 in /usr/local/psa/admin/plib/modules/wp-toolkit/library/Capability/WpCli/LocalPleskLinux.php on line 17
PHP Warning: Undefined array key 0; File: /usr/local/psa/admin/plib/modules/wp-toolkit/library/Capability/WpCli/LocalPleskLinux.php, Line: 74

PHP Warning: Undefined array key 0 in /usr/local/psa/admin/plib/modules/wp-toolkit/library/Capability/WpCli/LocalPleskLinux.php on line 74
NAME

wp

DESCRIPTION

Manage WordPress through the command-line.

SYNOPSIS

wp <command>

SUBCOMMANDS

admin-username Manage administrator username.
cache Adds, removes, fetches, and flushes the WP Object Cache
object.
cap Adds, removes, and lists capabilities of a user role.
cli Reviews current WP-CLI info, checks for updates, or
views defined aliases.
comment Creates, updates, deletes, and moderates comments.
config Generates and reads the wp-config.php file.
config-settings Manage config settings command
core Downloads, installs, updates, and manages a WordPress
installation.
cron Tests, runs, and deletes WP-Cron events; manages WP-Cron
schedules.
db Performs basic database operations using credentials
stored in wp-config.php.
db-prefix Manage database prefix.
embed Inspects oEmbed providers, clears embed cache, and more.
eval Executes arbitrary PHP code.
eval-file Loads and executes a PHP file.
export Exports WordPress content to a WXR file.
help Gets help on WP-CLI, or on a specific command.
i18n Provides internationalization tools for WordPress
projects.
import Imports content from a given WXR file.
instance Make init
language Installs, activates, and manages language packs.
maintenance-mode Manage maintenance mode.
media Imports files as attachments, regenerates thumbnails, or
lists registered image sizes.
menu Lists, creates, assigns, and deletes the active theme's
navigation menus.
network Perform network-wide operations.
option Retrieves and sets site options, including plugin and
WordPress settings.
package Lists, installs, and removes WP-CLI packages.
pingbacks Manage config settings command
plugin Manages plugins, including installs, activations, and
updates.
post Manages posts, content, and meta.
post-type Retrieves details on the site's registered post types.
release Get release information
rewrite Lists or flushes the site's rewrite rules, updates the
permalink structure.
role Manages user roles, including creating new roles and
resetting to defaults.
scaffold Generates code for post types, taxonomies, plugins,
child themes, etc.
search-replace Searches/replaces strings in the database.
security-keys Manage WordPress config's security keys
server Launches PHP's built-in web server for a specific
WordPress installation.
shell Opens an interactive PHP console for running and testing
PHP code.
shortcode Manage shortcodes
sidebar Lists registered sidebars.
site Creates, deletes, empties, moderates, and lists one or
more sites on a multisite installation.
sitemap Manage sitemap
super-admin Lists, adds, or removes super admin users on a multisite
installation.
taxonomy Retrieves information about registered taxonomies.
term Manages taxonomy terms and term meta, with create,
delete, and list commands.
theme Manages themes, including installs, activations, and
updates.
transient Adds, gets, and deletes entries in the WordPress
Transient Cache.
user Manages users, along with their roles, capabilities, and
meta.
widget Manages widgets, including adding and moving them within
sidebars.
wpt-asset Extends for Plugin_Command \ Theme_Command
wpt-cron



GLOBAL PARAMETERS

--path=<path>
Path to the WordPress files.

--url=<url>
Pretend request came from given URL. In multisite, this argument is how
the target site is specified.

--ssh=[<scheme>:][<user>@]<host|container>[:<port>][<path>]
Perform operation against a remote server over SSH (or a container using
scheme of "docker", "docker-compose", "docker-compose-run", "vagrant").

--http=<http>
Perform operation against a remote WordPress installation over HTTP.

--user=<id|login|email>
Set the WordPress user.

--skip-plugins[=<plugins>]
Skip loading all plugins, or a comma-separated list of plugins. Note:
mu-plugins are still loaded.

--skip-themes[=<themes>]
Skip loading all themes, or a comma-separated list of themes.

--skip-packages
Skip loading all installed packages.

--require=<path>
Load PHP file before running the command (may be used more than once).

--exec=<php-code>
Execute PHP code before running the command (may be used more than once).

--context=<context>
Load WordPress in a given context.

--[no-]color
Whether to colorize the output.

--debug[=<group>]
Show all PHP errors and add verbosity to WP-CLI output. Built-in groups
include: bootstrap, commandfactory, and help.

--prompt[=<assoc>]
Prompt the user to enter values for all command arguments, or a subset
specified as comma-separated values.

--quiet
Suppress informational messages.

Run 'wp help <command>' to get more information on a specific command.
 
@godfather21
I agree with @Sebahat.hadzhi that the correct way to execute "plesk ext wp-toolkit --wp-cli..." from Tools and Settings > Scheduled Tasks (Cron jobs) because when it run from Domains > example.com > Scheduled Tasks it is run under subscription user.
As for the error you provided, looks like the issue in command itself. Can you provide what goal are you going to reach and what commnd you execute to do it?
 
@godfather21
I agree with @Sebahat.hadzhi that the correct way to execute "plesk ext wp-toolkit --wp-cli..." from Tools and Settings > Scheduled Tasks (Cron jobs) because when it run from Domains > example.com > Scheduled Tasks it is run under subscription user.
As for the error you provided, looks like the issue in command itself. Can you provide what goal are you going to reach and what commnd you execute to do it?

I am trying to transfer wp all import cron jobs to run via wp-cli and this is the command

sudo plesk ext wp-toolkit --wp-cli -instance-id 3 --wp all-import run 16 --skip-plugins=false
 
You can try to run commands the following way:
plesk ext wp-toolkit --wp-cli -instance-id 3 -- all-import run 16 --skip-plugins=false --skip-themes=false
Please note that according to the message from plugin maintainer "all-import" CLI option available in paid version of the plugin only.
 
Back
Top