Setup a Cron Job

From AMember Pro Manual

Jump to: navigation, search

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.com/amember/cron.php) 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.com/amember/cron.php 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.

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:

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:

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.php

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.php
/usr/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron.php
/usr/local/bin/lynx -source http://yoursite.com/amember/cron.php
/usr/local/bin/curl -s http://yoursite.com/amember/cron.php
/usr/local/bin/wget -o/dev/null -O- http://yoursite.com/amember/cron.php

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

6. If nothing helps, you can use an external cron service, like this (we have no relation with these services):

Just add a cron job to access http://yoursite.com/amember/cron.php every hour (at 0 minutes). There is no security risk, because no secure date passed from or displayed by aMember cron job. Everything happens in background.