PeepSo Configuration #
PeepSo runs the built-in maintenance scripts and for the small sites, they are usually enough, but for the active and large sites, it is better to offload this process directly to server to improve performance. Some features like video uploads even require external cron job to be set. Before you start adding external cron jobs, please enable “External Maintenance Cron Job” in WP Admin -> PeepSo -> Configuration -> Advanced -> Cron jobs section.
Creating a New Cron Job #
Cron is the utility software installed on Unix-like computer operating system. In website development it is used to trigger a certain action at fixed times, dates, or intervals.
Adding the cron job is commonly done through the hosting CPanel interface. If you’re not sure how to access it, please consult your hosting provider.
- Common settings field allows you to select one of the commonly used configurations, like running the cron every minute, every 5 minutes, once a day etc. If you chose the common setting, the options in box #2 will be filled automatically.
- If you ever need to fine tune the cron schedule, you can do it here
- In this field, the command to execute should be entered. We will provide all, but you will need to modify them slightly to match the domain name or change the HTTP to HTTPS if you enable SSL certificate on your site.
Cron Command Structure #
Every cron command consist out of three parts. The software that is going to be used (wget, curl), the cron command (url in the middle)ย and additional arguments at the end (> /dev/null)
This third part of the cron command is particularly important.
We suggest using the one outlined bellow, but you can also opt for using different, or no arguments at all.
Examples:
- Our example (> /dev/null) – Sends a cron output to /dev/null and notifies the email owner set in cron MAILTO when errors or debug messages occur
- > /dev/null 2>&1 – Output is sent to /dev/null. No email is sent.
- No argument – log file is created, email is sent to MAILTO address set in cron.
What is /dev/null? #
It is just a special file on UNIX-like systems that accepts to be written but it never saves what’s written in it. Consider it be a book that is constantly being written, but it has no beginning, middle, or the end.
Maintenance Cron #
Maintenance Cron is part of PeepSo Foundation Plugin. Setup scripts that clean up orphaned data, recounts hashtags, deletes temporary videos, delete items that are no longer needed. You can set the cron interval to run every 5 minutes and it works best for most sites.
Commands you can use:
wget https://domain.com/?peepso_process_maintenance > /dev/null
or
curl https://domain.com/?peepso_process_maintenance > /dev/null
Mail Queue #
Mail queue is part of PeepSo Foundation Plugin. The email notifications that are queued will be sent in batches.
Before you setup the cron, make sure that the send mail function works properly, otherwise the email will stuck in the mail queue. You can set the cron interval to run every 5 minutes and it works best for most sites.
Commands you can use:
wget https://domain.com/?peepso_process_mailqueue > /dev/null
or
curl https://domain.com/?peepso_process_mailqueue > /dev/null
Additional parameters:
The Mail Queue cron accepts a limit parameter to override how many emails are sent per run. The default limit is 50. So if your site needs to send a thousand emails per hour, you can run the cron every 5 minutes with limit 100 (that’s 1200 emails per hour). For example:
curl https://domain.com/?peepso_process_mailqueue&limit=100
It also accepts a max_attempts parameter to override how many times an unsuccessful email is retried before being marked as failed. The default value is 5. Please bear in mind, retrying failing emails might slow your queue down.
curl https://domain.com/?peepso_process_mailqueue&max_attempts=10
The two parameters can be combined like this:
curl https://domain.com/?peepso_process_mailqueue&limit=100max_attempts=10
Controlling parameters without external cron:
If for some reason your hosting does not support cron jobs, and you have to rely on the WordPress scheduler, there is a way to control limit and max_attempts with PHP filters:
add_filter('peepso_process_mailq_limit', function($v) {ย ย return 100;ย ย },11,1);
add_filter('peepso_process_mailq_max_attempts', function($v) {ย ย return 20;ย ย },11,1);
Local Video Conversion Queue #
Video Conversion queue is part of Videos Plugin. The cron will convert videos that are queued. Conversion process is starting from the oldest to newest, one video in one process. You can set the cron interval to run every 15 minutes or it depend on your server capability. Bear in mind that Video Conversion are an advanced experimental feature in a BETA phase – one that comes with a number of strict technical requirements and limitations.
Commands you can use:
wget https://domain.com/?peepso_convert_videos_event > /dev/null
or
curl https://domain.com/?peepso_convert_videos_event > /dev/null
Amazon Elastic Transcoder Video Conversion Queue #
Similarly to local video conversion, you can offload this task to Amazon Elastic Transcoder
Use this commant when you enable that integration.
wget https://domain.com/?peepso_upload_videos_to_s3 > /dev/null
or
curl https://domain.com/?peepso_upload_videos_to_s3 > /dev/null
GDPR Queue #
GDPR queue is part of PeepSo Foundation Plugin. This cron triggers the execution for users who want to export their data. You can set the cron interval to run every 15 minutes.
Commands you can use:
wget https://domain.com/?peepso_gdpr_export_data_event > /dev/null
or
curl https://domain.com/?peepso_gdpr_export_data_event > /dev/null
Email Digest #
Email Digest Cron is part of Email Digest Plugin. The cron creates and send email digest data for users. You can set the cron interval to run every 15 minutes.
Commands you can use:
wget https://domain.com/?peepso_email_digest_event > /dev/null
or
curl https://domain.com/?peepso_email_digest_event > /dev/null
For Issues With Hosting Caching Solutions #
In some minor cases there are issues with cron jobs, when cron tasks are firing in very large intervals due to server caching solutions set in place by the specific hosting provider and ignoring the configured times.
As a workaround, you could try the following cron job modification (example for the video conversion):
wget -q -O /dev/null "https://domain.com/?peepso_convert_videos_event&cronid=`date +\%Y\%m\%d\%H\%M\%S`"
Adding &cronid=`date +\%Y\%m\%d\%H\%M\%S`ย to the cron task would force a new request each time, bypassing the caching solution and allowing the cron job to run at the specified times on server environments that utilize such server caching.
Using Third-Party Services To Schedule Cron Jobs #
If for whatever reason, setting up the Cronjob is not a possibility on your server, you can choose to offload this task to third-party provider.
We recommend EasyCron that can provide advanced webcron solutions for all common and tricky needs.
EasyCron is in the business of handling Cron jobs since 2010 and have over 140.000 customers happily using their service.
You can see the full instructions on how to setup Cron jobs on EasyCron website by following this tutorial.