KalAajKal.com :: Home Page  
Articles Quotations Lyrics Recipes Info               
Bookmark this Site  Set it as your HomePage                       
 
 
 Article Categories

  Animals articles  Animals
  Automobiles articles  Automobiles
  Business articles  Business
  Career articles  Career
  Computers articles  Computers
  Computer Programming articles  Computer Programming
  Entertainment articles  Entertainment
  Environment articles  Environment
  Family articles  Family
  Food articles  Food
  Health & Medical articles  Health & Medical
  Home & Garden articles  Home & Garden
  Humor articles  Humor
  Internet Marketing articles  Internet Marketing
  Legal articles  Legal
  Leisure & Recreation articles  Leisure & Recreation
  Marketing articles  Marketing
  Other articles  Other
  Politics articles  Politics
  Religion articles  Religion
  Sports articles  Sports
  Technology & Science articles  Technology & Science
  Travel articles  Travel
  Writing articles  Writing
  Finance articles  Finance
  Internet Business articles  Internet Business
  Communications articles  Communications
  Advice articles  Advice
  Self Improvement articles  Self Improvement
  Fashion articles  Fashion
  Reference & Education articles  Reference & Education
 
 
   


   
   
Categories :: Computers : Personal Tech Articles
 


 

Category :: Personal Tech Author :: Bernard Peh 
 
 Article Title :: How To Automate Tasks In Your Linux Server
 

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.

Bernard Peh is a great passioner of web technologies and one of the co-founders of Sitecritic.net. He works with experienced web designers and developers for more than 5 years, developing and designing commercial and non-commercial websites. More of his work can be seen at Sitecritic.net Internet articles.

 
More Personal Tech Articles 
 
 

Content that published and provided on this web site is for informational purposes only. We accept no responsibility for any loss, damages or inconvenience sustained by any person or authority resulting from information published on this web site. We encourage and request you to verify any critical information with the relevant authorities.

   
  Articles  |  Lyrics  |  Quotations  Facts  |  Plants  |  Names  |  Biography  |  Jokes  |  Recipes 
   
Copyright © 2007  KalAajKal.com.  All Rights Reserved.