• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.

Resolved Run plesk command as cronjob not working

Azurel

Silver Pleskian
EDIT: Solution is not to use "plesk bin <command>" and use instead "/usr/local/psa/bin/<command>" in cronjob.


I have created a php command-line script with command
Code:
shell_exec('plesk bin <command>');

As root in shell with putty that line is working!
Code:
# /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/myscript.php

I added it as cronjob (every minute) /etc/cron.d/myscript with this line
Code:
*/1 * * * * root /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/myscript.php

Now I get a cron mail with
sh: plesk: command not found

What am I missing here?
 
Last edited:
It's been more than one year but since it remains unanswered, I will reply to this old topic.

I had the same problem and didn't find anything which even mentioned this specific problem but only this topic. So I dug a little more and saw the KB article which told Plesk command line utilities could be run stand alone, without the plesk command itself. So instead of this:

PHP:
shell_exec('plesk bin <command>');
you should be using this:
PHP:
shell_exec('/usr/local/psa/bin/<command>');

For example if you want to run domain utility. Instead of this:

PHP:
shell_exec('plesk domain --do --something');
you need to run it with the full path of the "domain" utility like:
PHP:
shell_exec('/usr/local/psa/bin/domain --do --something');

P.S. You need to change the path accordingly if you are running on Windows. Like;
Code:
C:\\Program Files (x86)\\Parallels\\Plesk\\bin\\domain.exe
 
Thanks. Thats nice of you, however the answer is already in start post. See first line. ;)
 
Back
Top