• No results found

Setting cron job Linux/Unix operating systems using command-line interface

N/A
N/A
Protected

Academic year: 2021

Share "Setting cron job Linux/Unix operating systems using command-line interface"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

Overview

A cron job/scheduled task is a system-side automatic task that can be configured to run for an infinite number of times at a given interval. Cron/scheduled task allows you to schedule a command or a script to run at a specific time of day, or on a specific day of the week or at a particular time of day on a specific day of the month. It allow for scheduling down to the minute and up to an annual event.

The system-side automatic task in Windows operating system is known as Scheduled Task, and in a Linux/Unix operating system is known as Cron Job.

It is highly recommended that you set up a system-side cron job to frequently load the following cron/*.php page which are as follows:

1. http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php

2. http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/ get_webinar_notification_cron.php

System-side cron jobs can be set up for the following:

1. Setting cron job Linux/Unix operating systems using command-line interface. 2. Setting Cron job using cPanel version 11.

3. Setting Cron job using Plesk control Panel version 11. 4. Setting scheduled task on windows server 2008.

(2)

Setting cron job Linux/Unix operating systems using command-line

interface

The steps to setup a cron job via server command-line interface are as follows: Step:1 Log into the server command line interface.

You will need root-level permissions for this operation

Step:2 Confirm if any of the content retrieval programs are installed on the server viz. wget, GET, lynx etc. You need to install any one of the programs to setup the cron job.

Step:3 Edit the crontab configuration file with the following command # crontab -e

Step:4 Insert the URL in the crontab configuration file, in the following syntax */5 * * * * wget -O /dev/null

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php

If your help desk is configured for secure HTTP access (https://), then you need to configure the cron job with the following parameters:

*/5 * * * * wget -O /dev/null --no-check-certificate https://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php

The cron job configured in Step 4 will make the URL to execute after every 5 minutes.

Repeat the steps to insert the following URL in crontab configuration file for notifications

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/ get_webinar_notification_cron.php

(3)

Setting Cron job using cPanel version 11

The steps to setup a cron job using server cPanel version 11 are as follows

This guide assumes that the wget command is enabled for your system.

Step:1 Login to your server cPanel.

Step:2 Click on the Cron Jobs icon, under Advanced section of the cPanel home page, as shown:

Step:3 You will be directed to the page where you find the option to add a new cron job, as shown

(4)

Cron Email Insert the e-mail address to which the cron output will be sent. It is recommended this field is left blank; otherwise your inbox could fill up very quickly.

Common Settings

This drop down menu provides some common pre-set cron timings. We recommend not to use the pre-set cron settings.

Minute Select Every 5 minutes from the drop down menu, so that the URL gets executed after every 5 minutes interval.

Hour Select Every hour from the drop down menu, so that the URL gets executed after every hour.

Day Select Every day from the drop down menu, so that the URL gets executed every day.

Month Select Every month from the drop down menu, so that the URL gets executed every month.

Weekday Select Every weekday from the drop down menu, so that the URL gets executed on every weekday.

Command Insert the URL along with the wget command here. For example: wget -O /dev/null http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php

Step:4 Click Add New Cron Job to insert this cron job in the system.

The cron job configured in Step 3 will make the URL to execute after every 5 minutes.

Repeat the steps to insert the following URL in crontab configuration file for notifications

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/ get_webinar_notification_cron.php

(5)

Setting Cron job using Plesk control Panel version 11

The steps to setup a cron job using server Plesk control panel are as follows

This guide assumes that the wget command is enabled for your system.

Step:1 Login to your server Plesk control panel.

Step:2 Click Domains under General menu on the left hand side of the Plesk home page, and select your help desk domain.

Step:3 Click on Crontab icon, as shown

Step:4 You will be directed to the page where you find the option to add a new cron job, as shown

(6)

Switched on Check this box if you wish this cron to be up and running as soon as you insert it in the system.

Minute Specify after how many minutes this cron should execute the script. Insert */5 for the cron to run after every 5 minutes.

Hour Specify after how many hours this cron should execute the script. Insert * for the cron to run after every hour.

Day of the Month

Specify the day of the month this cron should execute the script. Insert * for the cron to run every day of the month.

Month Specify the month this cron should execute the script. Insert * for the cron to run every month.

Day of the Week

Specify the day of the week this cron should execute the script. Insert * for the cron to run every day of the week.

Command Insert the URL and wget command here. For example: wget -O

/dev/http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php

Step:5 Click OK to insert the new cron job in the system.

Repeat the steps to insert the following URL in crontab configuration file for notifications

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/ get_webinar_notification_cron.php

(7)

Setting scheduled task on windows server 2008

The steps to setup scheduled task on Windows 2008 server are as follows: Step:1 Login to your Windows 2008 server.

You will need Administrative privileges for this operation.

Step:2 Download the wget.exe application for Windows, from here. Place the wget.exe on your server at C:\Windows

Step:3 Access Task Scheduler from Start > Administrative Tools, as shown

Step:4 Click Create Task, as shown

You will be directed to the page where you need to specify the settings for the new scheduled task. This page is further divided into five configurable sections, which are:

(8)

1. General 2. Triggers 3. Actions 4. Conditions 5. Settings

Settings specific to these sections are explained as follows:

Name Specify a name for this scheduled task. Description Provide a short description for this task. Run whether user is

logged on or not

Select this option so that this schedule task should run even if there is no user is logged on this server.

(9)

Triggers

Click New to add a new trigger

Settings Select Daily, so that this task gets executed every day. Advanced

settings

Select "Repeat task every" option, and select "5 minutes" as the time of repetition. The duration must be set to "Indefinitely".

Enabled Select this option if you wish that this task should be up and running as soon as you insert it.

(10)

Actions

Click New to add a new action

Action Select Start a program as an intended action.

Settings Browse to the wget.exe application placed on your server, and select it. Arguments Specify the script URL here. For example,

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/send_email_cron.php. Specify the -q -O nul option in front of the URL, so as to suppress the

(11)
(12)

Uncheck the setting "Stop the task if it runs longer than" so that this task should run indefinitely. Rest of the settings need not be changed.

Repeat the steps to insert the following URL in crontab configuration file for notifications

http://website.com/wp-content/plugins/webinar_plugin/webinar-crons/ get_webinar_notification_cron.php

References

Related documents