• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

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