Black Friday Special

Administration

Cron Setup

Describing what is cron and how you can setup cron-job manually.
What is Cron ?
It’s like an alarm to tell you that you should do a task. Similarly it tells your server to do specific tasks on specific time intervals.

Why Do I need it ?
On triggering of Cron, payplans do following task.
→ Sending activation/expiration mails.
→ expiration of subscription
→ retrieving payments from payment gateways.

Way to setup :
There are 3 ways to setup cron :

  • Automatic Cron. Payplans handle it’s own. (don’t worry mode)
  • Server Cron with command line (portable and geek way)
  • Server Cron with CPanel (cool way)

  • Automatic cron :
    Payplans lets you to set automatic Cron run at Payplans Configuration. It will work on all type of hosting servers, like Linux, Windows etc.
    You can set timing in payplans configuration for Cron.

Configure cron in payplans config

Set the Cron Frequency as per the traffic on your site and how frequently you want to execute Cron on your site. If your site has more traffic then set the Cron frequency to low.
Set the "Run Automatic Cron" parameter to Yes in Expert section of configuration.

Set automatic cron in payplans config

When Micro-subscription is enabled in PayPlans Configuration then Cron execution will get 5 times more frequent to the frequency set in the configuration.
Cron execution will be dependent on your site, if your site has no-traffic then cron will not be executed.

  • Server Cron using command line:
    You can set this timing at server itself, follow below steps :

  • Run following command in terminal
    crontab -e

  • After running above command add this following line to end of file
    0,15,30,45 * * * * wget --max-redirect=10 'http://www.YOURDOMAIN.com/index.php?option=com_payplans&view=cron&task=trigger'
    it will trigger Cron after every 15 minutes, replace YOURDOMAIN with your site domain.

  • Just save it and setup is done.

    syntax for set cron

An operator allows you to specifying multiple values in a field. There are three operators:

  • The asterisk (*) : This operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month.

  • The comma (,) : This operator specifies a list of values, for example: "1,5,10,15,20, 25".

  • The dash (-) : This operator specifies a range of values, for example: "5-15" days , which is equivalent to typing "5,6,7,8,9,....,13,14,15" using the comma operator.

  • The separator (/) : This operator specifies a step value, for example: "0-23/" can be used in the hours field to specify command execution every other hour. Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.

  • Set the "Run Automatic Cron" parameter to Yes in Expert section of configuration.

    Set automatic cron in payplans config

  • Server Cron using CPanel :
    After login to your CPanel you will be redirected to the home page where you will find an option named Cron jobs, here you can add Cron job. For more details you can refer the documentation.
    Set the "Run Automatic Cron" parameter to "No" in Expert section of configuration.

    Set automatic cron in payplans config

Setting cron from CPanel

Related KB's :

Common Questions & Issues

  1. What are the pros and cons of using "Server Cron" instead of the "Automatic Cron"?
    Ans :- If you use Server Cron then you have more control over crons like on which date,time,day the cron will trigger.

  2. Should I disable the "Run Automatic Cron" in the "Expert Settings" once I configure the "Server Cron" or I can keep it enabled?
    Ans :- Yes, If you are using Server Cron then you should set Run Automatic Cron to "No",For example :- It might be the case that if you are using notification emailer then there could be chance that there will be multiple emails to user.

How to avoid server cron creating lots of trigger.php.xxxx files.

QUESTION : We are running the cron job from our server. It is working fine but we realised that every time the cron job is triggered, there is a file saved on our server root folder, named trigger.php.xxxx, where xxxx is an incremental number. This is something that we have to live with, or something that we can avoid, if we can, how?
SOLUTION : If you are using wget to request the cron page then use -q and -O (its capital O).
wget --max-redirect=10 -q -O cron.payplans "cron-url"
By using -O you can overwrite the same file, rather then creating multiple files.