Walkthrough: Setting Up Cron Jobs in Plesk (specifically AWS Linux Lightsail instance)

sunburstdigital

New Member
Hi everyone,

I had a lot of trouble getting my cron jobs to work in Plesk, and after hours of searching and contacting Plesk support, I got them working. In the hopes that my struggles can help others, below is everything I found out during my process. Our server is an AWS Lightsail instance, but I'm assuming this will work on any Linux server running Plesk.

1. In Plesk, Cron Jobs are called "Scheduled Tasks", which you can find under Tools & Settings, then look under the "Tools & Resources" header.

2. When adding a new task (cron job) for Mailwizz, select "Run a command" as the Task type. Then in the Command field, enter the text provided by Mailwizz, WITHOUT the asterisks and numbers before it. Such as:

/usr/bin/php -q /var/www/vhosts/domain.com/apps/console/console.php send-campaigns >/dev/null 2>&1

3. Under Run, select "Cron style" from the drop down menu. Copy/paste the asterisks/numbers provided into this field. Such as:

*/2 * * * *

4. I highly recommend giving each cron job a good description too, so you can keep them all organized. This is how it should look at this point:

Cron-Job-Screenshot.png

5. IMPORTANT: The default path to php binary in these commands will not work on Plesk. I received this info directly from Plesk support:

Plesk installs php in /opt/plesk/php Binary for php 7.4: /opt/plesk/php/7.4/bin/php Binary for php 8.0: /opt/plesk/php/8.0/bin/php

You may need to find out what versions of PHP your server is currently running, which you can do from Tools & Settings > PHP Settings.

Once you know the version of PHP to use, you'll need to update the command field as such. Where X.X equals the version of PHP:

replace this: /usr/bin/php with this: /opt/plesk/php/X.X/bin/php

Be sure to keep everything else in the command, including the -q. Click "Apply", then click "Run Now" and the task should run without errors.

6. If it's still not working, double check the spaces to ensure there are no missing or double spaces in the command. Copy/pasting from Mailwizz backend should help with this. It's possible cron isn't active on your server too (although I think it is active by default on Plesk installations), but may be worth double checking. If all else fails, contact Plesk support and they should be able to help.

Disclaimer: I don't plan to update this post. Information is accurate as of 2/21/23, but things can change, and this walkthrough may not be 100% accurate in the future.
 
Back
Top