How do I setup a cron jobs?
Created
Cron is a daemon that executes commands or "cron jobs" at specified intervals. For example, if you want to run http://example.com/cron.php every 15 minues, you can setup a cron job to do this automatically.
Note: Windows servers use a Scheduled Task to execute commands, some of the information listed here will not work on Windows servers.
1. Open your webhosts cron page:
- Cpanel: In the Advanced tab select the Cron Job option.
- Plesk: Go to Settings > Scheduled Tasks in the General Group. Select the system user account on whose behalf the task will be executed (usually the domain ftp user). Click "Schedule New Task". Specify when to run your command.
2. Command:
A cron command is setup in the following pattern:
minute hour day month weekday <command>
For example, to run a cron 15 minutes past every hour you would enter:
15 * * * * /usr/bin/lynx -source http://example.com/cron.php
If you specify */15 in the 1st field, it runs every 15 minutes as shown below.
*/15 * * * * /usr/bin/lynx -source http://example.com/cron.php
The same pattern can be applied to each of the minute, hour, day and/or month settings. You webhost panel may have a selectable option for the time selector. In this case you can simply enter the URL for the page you want the cron setup for.
Some examples:
If you are running the Checkout One Deluxe Tool Suite module and want to send cart reminders every 1 hour the following cron command can be used:
* */1 * * * /usr/bin/lynx -source http://example.com/checkout-one-cart-notifications.php
If you would like the notifications to be sent once a day at 1:15 you can use:
15 1 * * * /usr/bin/lynx -source http://example.com/checkout-one-cart-notifications.php
Note: The example here use Lynx. Lynx is the easiest way to activate cron.php, but Lynx is not installed by default in all versions of Linux. If the above command does not work you can try to use wget:
Note: Windows servers use a Scheduled Task to execute commands, some of the information listed here will not work on Windows servers.
1. Open your webhosts cron page:
- Cpanel: In the Advanced tab select the Cron Job option.
- Plesk: Go to Settings > Scheduled Tasks in the General Group. Select the system user account on whose behalf the task will be executed (usually the domain ftp user). Click "Schedule New Task". Specify when to run your command.
2. Command:
A cron command is setup in the following pattern:
minute hour day month weekday <command>
For example, to run a cron 15 minutes past every hour you would enter:
15 * * * * /usr/bin/lynx -source http://example.com/cron.php
If you specify */15 in the 1st field, it runs every 15 minutes as shown below.
*/15 * * * * /usr/bin/lynx -source http://example.com/cron.php
The same pattern can be applied to each of the minute, hour, day and/or month settings. You webhost panel may have a selectable option for the time selector. In this case you can simply enter the URL for the page you want the cron setup for.
Some examples:
If you are running the Checkout One Deluxe Tool Suite module and want to send cart reminders every 1 hour the following cron command can be used:
* */1 * * * /usr/bin/lynx -source http://example.com/checkout-one-cart-notifications.php
If you would like the notifications to be sent once a day at 1:15 you can use:
15 1 * * * /usr/bin/lynx -source http://example.com/checkout-one-cart-notifications.php
Note: The example here use Lynx. Lynx is the easiest way to activate cron.php, but Lynx is not installed by default in all versions of Linux. If the above command does not work you can try to use wget:
15 1 * * * wget -q -O - http://example.com/checkout-one-cart-notifications.php >/dev/null 2>&1
If the following does not work on your server will need to contact your webhost to find the best method of setting up a cron job for your server.
Was this article helpful?
1 out of 1 found this helpful.