Navigation       Home                            Contact                           Link

AMAZONTAGHERE6

 

ARTICLE PREVIEW

How to Create a Money Making Blog Empire in 30 Days
'What would you do if you had to start your internet business from scratch with no money at all?' This is a question that often pops up on the message boards of affiliate marketing sites. It...read more

How To Make Sure Your Email Is Ignored, Hated or Deleted in 2 Seconds
What I am about to say will make some people stand up and shout “hooray!” It will make others blush with embarrassment. Either way, take this advice and make your life a little bit easier. This...read more

How To Get The Best Home Equity Loan
Are you wondering how to get the best Home Equity loan? Do not be afraid to shop around. If you decide that the timing's right for a home equity loan, ask your friends or family for recommendations...read more

HOME >> How To Automate Tasks In Your Host Server

 

YOURIMAGEHERE3

How To Automate Tasks In Your Host Server
By Sitecritic .Net

 

 

If your host is running under the Linux (Unix) operating system, you can perform tasks in the server on a regular basis. For example, sending mails at a certain time of the day, backing up database at 6 in the morning and so on. "Cron" is a program that runs in the background of the Linux server. The program runs certain commands defined by you at fixed time intervals. A tyical cron file will look something like this:

# My Sample Cron File 12 01 02 * * /usr/bin/du /var > /home/test/diskSpace.txt

Cron command lines consist of 6 whitespace separated fields. The first 5 fields are used to specify when to run the command, and the last field determines what command to run. The first field(12 in this case) represents minute, the second field represents hour, third field represents day of month, fourth field represents month(1=Jan, 2=Feb and so on), fifth field represents day of week(0=sunday, 1=monday and so on).

Note: * means every time and # means comments.

To edit the crontab file, we use the crontab command like so:

"crontab [ -e | -l -r ]"

The switch -e means to edit the current cron file. -l means to list the current file, and -r means to remove the current cron file. Try typing "crontab -l" and you will see the cron file contents. To access the crontab command, you need to have SSH(Secure Shell) access to the server. Basically, SSH allows you to type commands in the command prompt. If you have limited access to SSH, your host might provide some other ways to access cron via the control panel.

For example, if I want to run a php script at 12 midnight everyday, I will type "crontab -e", then write my script as follows:

0 0 * * * php /home/username/public_html/www.sitecritic.net.php

The command that I run is "php". It is also recommended that you use full path reference to your script. In this case, it is /home/username/public_html/www.sitecritic.net.php.

In Conclusion, cron can save you alot of time and effort in doing daily repetitive tasks. By running a customised php script, you can automate the task of sending mass mails, backing up database, creating RSS feeds...etc.

About the author:

Sitecritic is formed by a group of web addicts, mainly volunteers from all over the world. Our goal is to create a community of web designers and developers who share the common interest in bringing out the best in creatiing effective web sites. More interest articles can be seen at Sitecritic.net Internet Articles

Return to HOME to read more articles
 

RSSTAGHERE4

 

COPYRIGHT © 2009-2015 HOW TO - ALL RIGHT RESERVED

 

CLICKBANKBUDDYTAGHERE5