Cronjobs

Cronjobs will automate your tasks, and ensure that everything on your server runs smoothly. Here, you will learn how create and run a cronjob in order to achieve the desired target.

Plesk Cronjob Setup

Cronjob allows email processing to run at the back end while not interfering with the site operations. In EasyDiscuss, cronjob is required to fetch emails, send emails, retrieve new tweets as blog and even import feeds remotely.


Plesk Setup

If you need to run scripts on your hosting account at a specific time, use the task scheduler in Plesk to make the system automatically run the scripts for you. There are some differences in the procedure for different Plesk version; this documentation is for Plesk 12.5.

Step 1

To create a scheduled task, go to Websites & Domains > Scheduled Tasks > Add Task.

Plesk Setup

First, depending on your purposes, you need to select the task type :

  • Command - Specify the full path to the executable file to be run. This includes binary files, shell scripts, and batch files.
  • Fetch a URL - Specify the URL only, there is no need to type the command, such as curl or wget.
  • Run a PHP script - Specify the path to the script relative to your virtual host directory. You can click the browse icon to quickly locate the script file.

Step 2

Next, you'll need specify which command to run and type it into the Command input box. Here is the example of the command and you'll need to change the directory of cron.php according to your site.

php -q /var/www/vhosts/www.site.com/components/com_easydiscuss/cron.php

Step 3

Next, go to your EasyDiscuss files and locate this file: .../components/com_easydiscuss/cron.php. At line 18, you will find this code. Please change the site.com to your site name so that it will work correctly. Save this file and proceed to Step 4.

######################################## 
##### Configuration options.
########################################

// This should not contain http:// or https://
$host = 'site.com';

########################################

Step 4

Next, select how often the task will run, and set the desired time and date. By default the time is in the server time zone; if you need to select a different time zone, go to Websites & Domains tab > Scheduled Tasks > Settings. You also have the ability to set a description for the task, and configure notifications.

Step 5

Finally, before saving the task, you have the option to do a test run to make sure that the task is configured correctly. Click Run Now and wait for the task to finish. If the task finishes with an error, it will also fail to work when executed by the scheduler, unless you find and resolve the issue first.

For further understanding, please visit Plesk customer guide