• 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

Issue /opt/plesk/php/8.0/bin/php /var/www/vhosts/mymainsite.com/sub.mymainsite.com/artisan schedule:run >> /dev/null 2>&1

XTech

New Pleskian
Server operating system version
Ubuntu 22.04.1 LTS
Plesk version and microupdate number
Plesk Obsidian Version 18.0.50
Hello All,
I need help to run the Cron jobs for every minute or so on my new script. the app says (Please set the following cron command on your server (Ignore if already done)
* * * * * (Every Minute))


This is what the script/app suggests to run the Cron jobs in the server. /opt/plesk/php/8.0/bin/php /var/www/vhosts/mysite.com/sub.mysite.com/artisan schedule:run >> /dev/null 2>&1

"Note: /opt/plesk/php/8.0/bin/php in the above command is the path of PHP on your server. To ensure it works correctly, please enter the correct PHP path for your server and provide the path to your script. If you're unsure how to set up a cron job, you may want to consult with your server administrator or hosting provider."

when I added the above command and run it, it gave me this error and the app says it is not running.
Task "/opt/plesk/php/8.0/bin/php /var/www/vhosts/mysite.com/sub.mysite.com/artisan schedule:run >> /dev/null 2>&1" completed with error in 0 seconds.

attached is the screenshot of the setup I have and not sure if this * * * * * means to run every minute.
Thank you and appreciate any help.
 

Attachments

  • Capture.PNG
    Capture.PNG
    58.2 KB · Views: 34
Hmm... I am not sure what app you're trying to trigger for the cron but what you could do, if it's a PHP script (which, if it's trying to pull from PHP version 8, it's more likely is), is to choose "Run a PHP script" instead, enter in the /var/www/vhosts/mysite.com/sub.mysite.com/artisan path, choose the PHP version, and try then.
 
@XTech seems like you're using a Laravel based application. You can use the Plesk Laravel Toolkit to manage that app, which includes the option enable a Cron jobs (Scheduled Task) that runs the artisan schedule:run command.
Schermafbeelding 2023-02-02 125824.png

Otherwise you can add a the command to a Scheduled Task like /opt/plesk/php/8.0/bin/php '/var/www/vhosts/example.com/sub.example.com/artisan' 'schedule:run'. No need to add >> /dev/null 2>&1 to the command.
 
Thank you Kaspar, I tried but still same error I have 2 versions of my Laravel app/script and the one I am trying to run the Cron job is PHP 7, and when I tried to run and I get this error.

Task "/opt/plesk/php/7.4/bin/php /var/www/vhosts/mysite.com/app.mysite.com/artisan schedule:run >> /dev/null 2>&1" completed with error in 0 seconds.
 
You can use like below screenshot. I have done it.

command = /opt/plesk/php/8.1/bin/php '/var/www/vhosts/domain/subdomain/artisan' schedule:run >> /dev/null 2>&1

Cron style = * * * * *
 

Attachments

  • Screenshot_10.png
    Screenshot_10.png
    53.3 KB · Views: 27
The solution where /opt/plesk/php/<version>/bin/php is used requires full SSH access. This will work only if created as a cronjob by admin or in a subscription where the shell is set to a non-chrooted shell. It will not work where the shell is set to the chrooted shell, because then the /opt path cannot be accessed from by subscription user. In that case, please follow @scsa20 's advice in his post above Issue - /opt/plesk/php/8.0/bin/php /var/www/vhosts/mymainsite.com/sub.mymainsite.com/artisan schedule:run >> /dev/null 2>&1 to run this not as a shell command, but only the PHP script part as a PHP script. The type of execution can be set on the crontab configuration page.
 
Back
Top