RO Users

Article Index

How to install RO Users - Cron job

Cron job

Cron command requirements

The cron command is a combination of a few settings:

  1. The PHP executable
  2. The path to cron.php
  3. The arguments

Let's take a closer look at these requirements.


PHP executable

The PHP executable is the program that processes the cron script. How the PHP executable is called completely depends on your host, check with them where your PHP executable resides. Some examples of the PHP executable are:

  • php
  • /usr/local/bin/php
    This is often PHP 5.3 and unsupported
  • /usr/local/bin/php55
    This will use PHP 5.5.x
  • /usr/local/bin/php56
    This will use PHP 5.6.x
  • /usr/local/bin/php70
    This will use PHP 7.0.x

Make sure to check with your host how to call the correct PHP version for your system.

Path to the cron job file

The file that processes the user accounts is called rouser.php, this file can be called directly from the command line. The file is located in /cli/rouser.php. It is important to know where the file is as you need to use the path to build the cron command. The full path needs to be the complete path to the rouser.php file. The full path depends on your host, check with them what your path needs to be. Some examples of the full path are:

  • /home/domain/public_html/cli/rouser.php
  • /www/cli/rouser.php

Arguments for the script

There are several arguments that need to be passed on to make the script work. These arguments are:

  • --username

A username of a user account that is allowed to delete users

  • --password

The password belonging to the supplied username.

  • --hostname

The URL of the website. This is used to create the opt-out link in the email sent out to users.

Build the cron command

With all the requirements in place we can build the cron command. The command is build up in this order:
PHP executable path to the rouser.php arguments

Including the arguments the full command can look like this:

/usr/local/bin/php /home/domain/public_html/cli/rouser.php --username="admin" --password="admin" --hostname="https://example.com/"

Make sure this command is all on one line. In a cron job you cannot span a command across multiple lines.

Need help?

The cron command comes with a built-in help screen. You can get the help screen by issuing this command:

/usr/local/bin/php /home/domain/public_html/cli/rouser.php --help

Setting up the cron command

How to setup the cron command depends on your host. Check with them how to set it up for your site. There are 2 control panel systems used often, these are cPanel and DirectAdmin, instructions for these follow here.

cPanel

  1. Login to cPanel for your site
  2. Click on Cron Jobs in the Advanced area.
    cPanel advanced cron
  3. Select the time you want the job to run in the Add New Cron Job
  4. Fill in your cron command in the Command box
    cPanel cron setting
  5. Click on Add New Cron Job
  6. The job is now scheduled

DirectAdmin

  1. Login to DirectAdmin for your site
  2. Click on Cronjobs in the Advanced Features area
    directadmin advanced cron
  3. Fill in the time you want the job to run in the Create a New Cron Job
  4. Fill in your cron command in the Command box
    directadmin cron setting
  5. Click on Add
  6. The job is now scheduled

The output

The script will output what it has done and the output looks like this:

Starting up the magic box...
Start clearing the queue
Done clearing the queue
Start cleaning out the bounced emails
Bounce messages found: 2
Finished cleaning out the bounced emails
Start queueing users
Going to add 464 users to the queue
Done queueing users
Start processing users with no last visit date
End processing users with no last visit date
Start sending first reminders
Sending a first reminder to 5 users
Done sending first reminders
Start sending second reminders
Done sending second reminders
Start processing deletions
End processing deletions
Shutting down the magic box...