MayurS Blog
Friday, February 12, 2010
Cron Tab
• 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 AttributesListed 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:
Box Properties
|
Saturday, November 21, 2009
Gone are the days
When
The school reopened in June,
And we settled in our new desks and
benches!
When we queued up in book depot,
And got our new books and notes!
When we wanted two Sundays and no Mondays ,
Yet managed to line up daily for the morning prayers.
We learnt writing with slates and pencils, and
Progressed To fountain pens and ball pens and then Micro tips!
When we began drawing with crayons and evolved to
Color pencils and finally sketch pens!
When we started calculating
first with tables and then with
Clarke's tables and advanced to
Calculators and computers!
When we chased one another in the
corridors in Intervals , and returned to the classrooms
Drenched in sweat!
When we had lunch in classrooms, corridors,
Playgrounds,
under the trees and even in cycle sheds!
When all the colors in the world ,
Decorated the campus on the Second Saturdays!
When a single P.T. period in the week's Time Table,
Was awaited more eagerly than the monsoons!
When cricket was played with writing pads as bats ,
And Neckties and socks rolled into balls!
When few played
"kabadi" and "Kho-Kho" in scorching sun,
While others simply played
"book cricket" in the
Confines of classroom!
Of fights but no conspiracies,
Of Competitions but seldom jealousy!
When we used to
watch Live Cricket telecast,
In the opposite house in Intervals and Lunch breaks!
When few rushed at 3:45 to
"Conquer" window seats in our School bus!
While few others had "Big Fun", "peppermint" ,
"kulfi", " milk ice !" and "sharbat !" at 4o Clock!
Gone are the days
Of Sports Day,
and the annual School Day ,
And the one-month long
preparations for them.
Gone are the days
Of the stressful Quarterly,
Half Yearly and Annual Exams , And the most
enjoyed holidays after them!
Gone are the days
Of tenth and twelfth standards, when
We Spent almost the whole year writing revision tests!
We learnt,
We enjoyed ,
We played,
We won,
We lost,
We laughed,
We cried,
We fought,
We thought.
With so much fun in them, so many friends,
So much experience, all this and more!
Gone are the days
When we used
to talk for hours with our friends!
Now we don't have time to say a 'Hi'!
Gone are the days
When we played games on the road!
Now we
Code on the road with laptop!
Gone are the days
When we saw stars
Shining at Night!
Now we see stars when our code doesn't
Work!
Gone are the days
When we sat to chat with Friends on grounds!
Now we chat in chat rooms.....!
Gone are the days
Where we
studied just to pass!
Now we study to save our job!
Gone are the days
Where we had no money in our pockets and still fun filled on our hearts!!
Now we have the atm as well as credit card but with an empty heart !!
Gone are the days
Where we shouted on the road!
Now we don't shout even at home
Gone are the days
Where we got lectures from all!
Now we give lectures to all... like the one I'm doing now ....!!
Gone are the days
But not the memories, which will be
Lingering in our hearts for ever and ever and
Ever and ever and ever .....
Gone are the Days...... But still there are lot more Days to come in our Life!!
NO MATTER HOW BUSY YOU ARE ,
DONT FORGET TO
LIVE THE LIFE THAT STILL
EXISTS..... :)
Saturday, August 8, 2009
कलियुगातील गोष्ट
प्रामाणिक (ला)कोड तोड्या
कलियुगातील गोष्ट आहे.
एका गावात दोन (ला)कोड तोडे म्हणजेच साहेबी भाषेत Software Engineers राहत होते. पोटाची खळगी भरण्यासाठी दोघेही कोडिंग करायचे. त्यांतील एक कोड तोड्या प्रामाणिक होता तर दुसरा लबाड होता. सकाळी उठायचे, न्याहरी करून ऑफिस मधे जायचे, Source Tree वर चढून कोड तोडायचे (cut copy paste), दुपारच्याला सब वे मधून बांधून आणलेले फुट लॉंग खायचे, अंमळ विश्रांती घ्यायची, आणि मग उशिरापर्यंत राब राब राबून अंधार पडला की घरी परतायचे असा त्यांचा दिनक्रम असे.
एके दिवशी काय झाले, प्रामाणिक कोड तोड्याचे कामात मन लागत नव्हते. म्हणून आपल्या खुराड्या(cube) मधे बसून कोड तोडण्या ऐवजी तो ऑफिसच्या आवारातल्या पोहण्याच्या तलावापाशी जाऊन बसला. तलावाकाठी बसून लॅपटॉप घेऊन कोड तोडू लागला. बघता बघता त्याला जराशी डुलकी लागली आणि त्याचा लॅपटॉप तलावात पडला. प्रामाणिक कोड तोड्याला खडबडून जाग आली आणि लॅपटॉप पाण्यात पडलेला पाहून तो रडू लागला. त्याला रडताना पाहून एक जलदेवता पाण्यातून बाहेर आली आणि तिने कोड तोड्याला विचारले,
"कोड तोड्या, तू का बरे रडत आहेस ?"
कोड तोड्याने रडत रडत तिला सांगितले
"माझा लॅपटॉप कोड तोडता तोडता पाण्यात पडला. माझ्याकडे दुसरा लॅपटॉप नाही. माझी उद्या डेडलाईन आहे. ती पूर्ण झाली नाही तर माझे कसे होणार ? घरी म्हातारे आई वडील आहेत. त्यांचे कसे होणार ?"
जलदेवता म्हणाली, "रडू नकोस. मी तुझा लॅपटॉप पाण्यातून बाहेर काढून देते."
इतके म्हणून जलदेवतेने पाण्यात बुडी मारली आणि ती एक लॅपटॉप घेऊन बाहेर आली. कोड तोड्याने कन्फिगरेशन पाहिले. हा लॅपटॉप 4 GB RAM चा होता. प्रामाणिक कोड तोड्या म्हणाला,
"हा लॅपटॉप माझा नव्हे. माझा लॅपटॉप तर 1 GB RAM चा होता."
जलदेवतेने पाण्यात पुन्हा बुडी मारली आणि ती अजून एक लॅपटॉप घेऊन बाहेर आली. कोड तोड्याने कन्फिगरेशन पाहिले. हा लॅपटॉप 2 GB RAM चा होता. प्रामाणिक कोड तोड्या म्हणाला,
"हा लॅपटॉप माझा नव्हे. माझा लॅपटॉप तर 1 GB RAM चा होता."
जलदेवतेने पाण्यात तिस-यांदा बुडी मारली आणि ती एक लॅपटॉप घेऊन बाहेर आली. कोड तोड्याने कन्फिगरेशन पाहिले. हा लॅपटॉप 1 GB RAM चा होता. प्रामाणिक कोड तोड्या म्हणाला,
"हाच माझा लॅपटॉप !!"
जलदेवता कोड तोड्याच्या प्रामाणिकपणावर खूश झाली आणि तिने ते तीनही लॅपटॉप प्रामाणिक कोड तोड्याला बक्षीस देऊन टाकले.
दुस-या दिवशी प्रामाणिक कोड तोड्याच्या मित्राने त्याच्याकडे नवीन लॅपटॉप पाहिला. त्याने विचारले, "मित्रा, या इकॉनॉमी मधे तुझ्याकडे नवीन लॅपटॉप कुठून आला ?" प्रामाणिक कोड तोड्याने त्याला जलदेवतेबद्दल सांगितले. ते ऐकून लबाड कोड तोड्याच्या मनात लोभ निर्माण झाला.
दुस-या दिवशी लबाड कोड तोड्या पोहण्याच्या तलावापाशी जाऊन बसला. तलावाकाठी बसून लॅपटॉप घेऊन कोड तोडू लागला. थोड्या वेळाने त्याने आपला लॅपटॉप मुद्दाम तलावात टाकला आणि मोठ्याने रडू लागला. त्याला रडताना पाहून जलदेवता पाण्यातून बाहेर आली आणि तिने कोड तोड्याला विचारले,
"कोड तोड्या, तू का बरे रडत आहेस ?"
कोड तोड्याने रडत रडत तिला सांगितले,
"माझा लॅपटॉप कोड तोडता तोडता पाण्यात पडला. माझ्याकडे दुसरा लॅपटॉप नाही. माझी उद्या डेडलाईन आहे. ती पूर्ण झाली नाही तर माझे कसे होणार ? घरी म्हातारे आई वडील आणि बायका पोरे - नाही नाही - बायको आणि पोरे आहेत. त्यांचे कसे होणार ?"
जलदेवता म्हणाली,
"रडू नकोस. मी तुझा लॅपटॉप पाण्यातून बाहेर काढून देते."
इतके म्हणून जलदेवतेने पाण्यात बुडी मारली. या खेपेस थोडे Optimization करून ती तीन लॅपटॉप घेऊन बाहेर आली आणि कोड तोड्याला विचारले,
"यातला कोणता लॅपटॉप तुझा होता ?"
लबाड कोड तोड्याने कन्फिगरेशन्स पाहिली. तो म्हणाला,
"माझा लॅपटॉप 4 GB RAM चा होता."
जलदेवतेला लबाड कोड तोड्याचा खोटेपणा आवडला नाही आणि ती लबाड कोड तोड्याला कोणताच लॅपटॉप न देता अदृश्य झाली.
कलियुगाचा महिमा :
प्रामाणिक कोड तोड्या तीन लॅपटॉप घेऊन आयुष्यभर कोडिंगच करत राहिला.
लबाड कोड तोड्याचा लॅपटॉप पाण्यात पडल्याने त्याला कोड लिहिता येईना. मग कंपनीने त्याला मॅनेजर बनवून नवीन ब्लॅकबेरी घेऊन दिला