• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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