Your Cart is Empty Reseller Login or Sign up FAQ Search

How to set up cron jobs on a dedicated server

Imagine that a client of yours, whose business grows immensely, needs you to allocate more web space, bandwidth and resources to their representative website, but you are not sure how to proceed? The Free Reseller Program will help you expand your own web hosting business with the new reselling options that it is offering - low-cost Dedicated Servers, Virtual Private Servers and Semi-Dedicated Servers, based on stable hardware/software configurations.

Your new Dedicated Server will surely need both system and user cron jobs to be set up on it, so that it can automatically work on most tasks. Here you will find a few useful examples on how to put a cron job into use on your scripting based websites. Scripts usually come with a working environment sophisticated enough to work as a multi-structural base for performing a wide variety of tasks which altogether are easily implemented and combined into forums, informational portals, blogs, management and billing systems, etc. Although most of the script's implementation is done in real time and the users operate with a web driven GUI to navigate through what the given script might offer, there are still some 'assignable' tasks that only site administrators can schedule. Those tasks are what we call cron jobs - they carry out important site / script maintenance information and pass system commands to the Cron Daemon via Crontab. Cron jobs are scheduled to execute shell / script commands at a given time or date. Below, you will find a couple of examples representing a shell command execution cron job and a script (CGI / PHP) execution cron job. Cron jobs have the following formatting, which we will divide into groups:

Cron job time schedule - [ Minute - Hour - Day - Month - Weekday ]

Cron job shell command - [ARGUMENTS]

Cron job script command - [PATH OF PHP/PERL] [ARGUMENTS] [PATH OF PHP SCRIPT]

Here is an example of cron job time scheduling and the allowed cron job operators:

.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed

* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekdays

You can create cron jobs via your cPanel Control Panel. Simply navigate to Advanced > Cron Jobs. In this section of the Control Panel you will see the cron jobs already created and you can also add new ones. To set up a cron job, you must specify the e-mail address where the results will be sent to, the date and time when the job should be executed and the command, which should be executed.

Here is an example of running shell command driven cron jobs and script execution cron jobs:

0 * * * * rm -f * /home/www/my-best-domain.com/temp/

This command will initiate the rm (remove / delete) utility for file/folder deletion and will forcibly ( -f stands for force which basically deletes the files without asking for permission prior to engaging the command) delete all files under the given system path which is the temp/ directory under /home/www/my-best-domain.com/.

Let us say that you want to send newsletters, site updates, etc. to your clients on a daily basis. Most script systems already have prebuilt scripts for this purpose and many more automated services. The cron job would look like:

0 0 0 0 * /usr/bin/php /home/www/my-best-domain.com/mailcron.php

There are also several useful additions to cron jobs, such as for example MAILTO=debug@my-best-domain.com, which will send you the output of the cron job, which in many cases is a very useful option, especially when your cron job is not working according to plan and produces errors. With the mailed output, you will be surely able to debug the issue. Such a cron job would look like this:

0 0 0 0 * /usr/bin/php /home/www/my-best-domain.com/mailcron.php MAILTO=email@my-best-domain.com

Reselling dedicated hosting services has never been so easy. You can sell VPS Servers, Semi-Dedicated Servers as well as Dedicated Servers. The services are smartly implemented in your Reseller Control Panel and are based on a ready-to-go strategy that allows you to start offering dedicated hosting packages without having any complex training or prior experience/knowledge in the field of web hosting.

« Back to menu