Difference between revisions of "Cron"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "== What is a cron job? == The cron job is a sheduled task on the hosting server. You may choose to run specific program in specific time, periodically. In case of aMember Pro, we...")
 
Line 1: Line 1:
 
== What is a cron job? ==
 
== What is a cron job? ==
The cron job is a sheduled task on the hosting server. You may choose to run specific program in specific time, periodically. In case of aMember Pro, we have to call aMember Pro page (yes, just regular page: ''http://yoursite.int/amember/cron.php'') with browser. However, your hosting is using Linux/Unix, so there are no usual browsers like IE or Netscape.
+
The cron job is a sheduled task on the hosting server. You may choose to run specific program in specific time, periodically. In case of aMember Pro, we have to call aMember Pro page (yes, just regular page: ''http://yoursite.int/amember/cron'') with browser. However, your hosting is using Linux/Unix, so there are no usual browsers like IE or Netscape.
  
 
We will use command-line text mode browser, named Lynx. You may run it on Unix with the following command: ''/usr/bin/lynx -source''
 
We will use command-line text mode browser, named Lynx. You may run it on Unix with the following command: ''/usr/bin/lynx -source''
Line 36: Line 36:
 
4. On the next day, if you receive e-mail notifications from "Cron Daemon" that says that something is wrong with your command,
 
4. On the next day, if you receive e-mail notifications from "Cron Daemon" that says that something is wrong with your command,
 
please read it carefully. It means that your cron job doesn't work. If it says "Command not found" , try to use the following command lines:
 
please read it carefully. It means that your cron job doesn't work. If it says "Command not found" , try to use the following command lines:
<pre>/usr/bin/curl -s http://yoursite.com/amember/cron.php
+
<pre>/usr/bin/curl -s http://yoursite.com/amember/cron
 
/usr/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron
 
/usr/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron
 
/usr/local/bin/lynx -source http://yoursite.com/amember/cron
 
/usr/local/bin/lynx -source http://yoursite.com/amember/cron

Revision as of 16:55, 26 October 2011

What is a cron job?

The cron job is a sheduled task on the hosting server. You may choose to run specific program in specific time, periodically. In case of aMember Pro, we have to call aMember Pro page (yes, just regular page: http://yoursite.int/amember/cron) with browser. However, your hosting is using Linux/Unix, so there are no usual browsers like IE or Netscape.

We will use command-line text mode browser, named Lynx. You may run it on Unix with the following command: /usr/bin/lynx -source

Line /usr/bin/lynx -source http://yoursite.int/amember/cron will access specified URL and display HTML source of page. In our case, we don't need any output, we just need our page to be accessed, so we will ignore output.

Why I need to set cron job ?

In aMember cron job required to handle recurring billing for some payment plugins, and periodic emails (not completed notifications, expire notifications, automatic emails). Even if you don't plan to use recurring billing or send automatic emails from aMember, we still recommend to setup external cron job , because it execute some necessary system tasks.


Setting it up

We will provide here instructions for CPanel-based control panel. I hope you will be able to find equivalent controls if your hosting uses different panel software.

1. Login into your webhosting control panel. You will see a screen like that:

<pimg src="CronCpanel.gif" width="207" />

2. Click to Cron Jobs link. It may be also hidden in Tools or Advanced submenu. You will see screen offering you to choose your expirience level. Choose Advanced.

3. You will see the following screen:

<pimg src="CronCpanel2.gif" width="251" />

Into the empty bottom line, enter:

Minute = 0
Hour = * (every hour)
Day = * (means every day)
Month = *
Weekday = *
Command = /usr/bin/lynx -source http://yoursite.com/amember/cron

Of course, replace yoursite.com to your actual domain name. Ensure that this URL works, first try to open it from your browser. Click Commit Changes

4. On the next day, if you receive e-mail notifications from "Cron Daemon" that says that something is wrong with your command, please read it carefully. It means that your cron job doesn't work. If it says "Command not found" , try to use the following command lines:

/usr/bin/curl -s http://yoursite.com/amember/cron
/usr/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron
/usr/local/bin/lynx -source http://yoursite.com/amember/cron
/usr/local/bin/curl -s http://yoursite.com/amember/cron
/usr/local/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron

5. Enable External Cron at aMember CP -> Setup -> Advanced.

6. If your webhosting does not allow Cron Jobs or you can't get it working with your hosting, you can setup cron job to be executed from your account at http://www.amember.com/amember/member

<pimg src="AMember_Cron_Tab.png" width=250/>

Just specify your installation's cron url in "Add new cron job" input and click "Add" button. There is no security risk, because no secure data passed from or displayed by aMember cron job. Everything happens in background.