• 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.

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