Friday, February 12, 2010

Cron Tab

his cron tutorial is divided into these subheadings for you to follow it easily:
• What is cron?
• What is cron tab?
• What cron will do for you?
• Have your web server cron enabled?
• What are the components of cron?
• Examples on how to set up cron
• Setting up the cron
o METHOD ONE: Using Cron tab manager
o METHOD TWO: Uploading ‘cron.txt’ file and checking using telnet
 Telnet commands
 Telnet steps (Four steps)
• Cron emails you everytime it runs. How to stop it?
• TIPS in setting up your cron jobs

What is cron?
Actually it is called ‘cron daemon’. Cron is an automatic task machine. You will use it on your Unix or Linux operating systems for doing some tasks at specific intervals with out your intervention every time. You set the clock and forget. The cron daemon runs the work for you.
What is cron tab?
‘Cron tab(CRON TABle)’ is a text file that contains a series of cron functions.
What cron job will do for you?
* If you want to send your email cources to your subscribers at 11.30 night, you will set the cron job on your server. And your cron manager sends one email every day at 11.30 until all the emails will be finished. If you want to send them on Sundays, you can schedule it with your cron.
* You can schedule it to delete your website members with expired accounts.
* You can schedule it to recieve an update on your subscribers from your mailing list manager.
* You can check your links on other websites in link exchange programms.
Have your web server cron enabled?


Have you seen any icon with a name ‘Cron Jobs’ in your control panel?
Have you seen a text link like ‘Cron Manager’ or ‘Cron jobs’?
If you see one, then you are cron enabled. Ask your host about your cron availability. Some host allows cron with out graphical interface. You have to access it through telnet. If you are hosted on Virtual hosting domains then your system administrator has to set up your cron tabs for you.
What are the components of cron?


1: Path to your php or cgi script
2: minutes (Value is 00 – 59. exact minute the cron executes)
3: hour (Value is 00 – 23. hour of the day the cron executes. 0 means midnight)
4: month (Value is 01 – 12. month of the year the cron executes)
5: day (Value is 01 – 31. day of the month the cron executes)
6: weekday (Value is 00 – 06. day of the week the cron executes. Sunday=0,Monday=1…)
Examples on how to set up cron:
If you have installed a php script in your public_html/www/html directory called members.php.
If you want to run this file each night at 11.30 PM every day:

30 23 * * * /home/username/www/members.php
30 – represents the minute of cron work
23 – represents the hour of the day
The * represent every day, month, and weekday.
If you want to set the cron job every sunday at midnight 11.30 PM:

30 23 * * 0 /home/username/www/members.php
0 – represents the Sunday.
If you want the cron job to run at 1:00 and 2:00 A.M:

* 1,2 * * * /home/username/www/members.php
This runs your cron at 1A.M and 2A.M every day, every month and every week.
If you want to run the above task only from Monday to Friday and at 11.30 P.M:
30 23 * * 1-5 /home/username/www/members.php
This runs your cron from Monday to Friday and everyday at 11.30 PM.
Setting up the cron:
• METHOD ONE: Using Cron tab manager
If you have a cron tab manager in your webpanel, it will be easy for you to set the cron tab function. You can click on the icon to open cron manager. There will be some textarea where you can enter the the script file path that you want the cron job to executes.
Your cron manager may be different from the above image, but basically it is easy to set up cron job with your cron manager. I highly recommend this unless you want to get to know about the Second Telnet Method.
• METHOD TWO: Uploading ‘cron.txt’ file and checking using telnet
* Cron Commands:
crontab filename Install filename as your crontab file
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.

* Telnet Steps:
Basically FOUR steps:
1. Create cron.txt
2. Upload
3. Install the txt file as cron file with the command ‘crontab cron.txt’
4. Check your cron file
1. Open your notepad on your computer and write cron job following the guidelines explained above under ‘What are the components of cron?’.
For example – If you write your cron job like this:
30 23 * * * /home/username/www/members.php
After writing the above cron job PRESS return key so that a blank line will be there below the cron job line.
2. Always use absolute path for the command line. Turn off the ‘Word Wrap’ feature with the Notepad.
3. Save the file as ‘cron.txt’. Upload it to your root directory (’/') where you will see a list of folders like public_html,public_ftp,email etc,. Or ask your web host where to upload the cron files. Upload in ASCII mode.


When you ftp into your site, first you will land on your root directory.
4. Now telnet into your server.
5. You have to use telnet software like putty to login into your server.


At command prompt type -
crontab cron.txt
Press Enter.
You will be back at command prompt.
Then type: (l means lowercase L)
crontab -l
Press Enter.
You will see the list of cron jobs that you have entered in cron.txt.
That’s it!!
Cron emails you everytime it runs. How to stop it?
Add this tag at the end of your cron job:
>/dev/null 2>&1
Taking the above example your cron job looks like:
30 23 * * * /home/username/www/members.php>/dev/null 2>&1
TIPS in setting up your cron jobs:
* Ask your host about the procedure if you are not sure of a thing.
* Check your cron once in a while. For example you set your cron to send your ezine at 11.30 PM. Then you subscribe yourself to see it is working or not.
* Upload cron.txt in ASCII mode.
* If you are setting the script path in your schedule, the path SHOULD be from your hosts server root. NOT your domain path.
Ex:/home/user/www/scriptname.php
is correct.
http://www.yourdomain.com/scriptname.php
is incorrect.
* Script names are case sensitive on Unix. So be careful in entering the script name.
* If you are creating cron.txt file and uploading, you should not allow spaces within 1-5 components except between them. (For example 10,30 * * * * is correct not 10 ,30 * * * *)

JavaScript Style Attributes

JavaScript Style Attributes

Listed below are the tables of CSS properties for various HTML element style attributes. I have added a column indicating the javaScript name that the browser recognizes for these properties. I have only listed those that I know work, but the trend seems to be to use the same name when one name is the style descriptor. When there are two names, use the first name in lower case and the first character of the second name in upper case. Examples:
  • color = color
  • background-color = backgroundColor
  • font-style = fontStyle
  • font-weight = fontWeight

Box Properties

Name JavaScript Name Description Possible Values Element Types Example inherited
border Sets border width, style and color. See border width, style, and color All {border: medium solid green} No
border-bottom Set the bottom border width style, and color. See border width, style, and color All {border-bottom: medium solid green} No
border-bottom-width Set the bottom border width thin, medium, thick, or length value All {border-bottom-width: thin} No
border-color Set the border color A color value, color, #RRGGBB All {border: #0000ff} No
border-left Set the left border width style, and color. See border width, style, and color All {border-left: medium solid green} No
border-left-width Set the left border width thin, medium, thick, or length value All {border-left-width: thin} No
border-right Set the right border width style, and color. See border width, style, and color All {border-right: medium solid green} No
border-right-width Set the right border width thin, medium, thick, or length value All {border-right-width: thin} No
border-style Sets border style none, dotted, dashed, solid, double, groove, ridge, inset, outset All {border: dashed} No
border-top Set the top border width style, and color. See border width, style, and color All {border-top: medium solid green} No
border-top-width Set the top border width thin, medium, thick, or length value All {border-top-width: thin} No
border-width Sets Border width. thin, medium, thick, or length value All {border-width: 8} No
clear Determines where floating elements are allowed. none, left, right, both All {clear: left} No
float Specifies how text is wrapped and where it is aligned. none, left, right All {float: left} No
height Height of element auto or a height value Block elements and IMG, INPUT, TEXTAREA, SELECT, and OBJECT {height: 200} No
margin Set element margin width. A single value sets all margins, two values set top and bottom, four values set top, right, bottom, and left margins. auto, length value, or percent value All {margin: 4em 2em 4em 2em} No
margin-bottom marginBottom Set element bottom margin length value, or percent value All {margin-bottom: 4em} No
margin-left marginLeft Set element left margin length value, or percent value All {margin-left: 4em} No
margin-right marginRight Set element right margin length value, or percent value All {margin-right: 4em} No
margin-top marginTop Set element top margin length value, or percent value All {margin-top: 4em} No
padding Space between border and content. A single value sets all sides, two values set top/bottom and left/right, three values set top, right/left, and bottom, and four values set top, right, bottom, and left. length value, or percent value All {padding: 4em} No
padding-bottom Space between bottom border and content. length value, or percent value All {padding-bottom: 4em} No
padding-left Space between left border and content. length value, or percent value All {padding-left: 4em} No
padding-right Space between right border and content. length value, or percent value All {padding-right: 4em} No
padding-top Space between top border and content. length value, or percent value All {padding-top: 4em} No
width Width of element auto or a height value in length or percentage Block elements and IMG, INPUT, TEXTAREA, SELECT, and OBJECT {width: 40em} No