Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Development (http://www.go4expert.com/articles/web-development/)
-   -   Crontab Tutorials (http://www.go4expert.com/articles/crontab-tutorials-t1925/)

Andrew 17Nov2006 21:23

Crontab Tutorials
 

What is crontab?



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 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 the 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 programs.

What are the components of cron?


Code:

+--------+---------+--------------------------------------------------------------------------------+
|Field  |  Value  |Description                                                                            |
+--------+---------+--------------------------------------------------------------------------------+
|minute  |  00-59  | exact minute the cron executes                                                |
+--------+---------+--------------------------------------------------------------------------------+
|hour    |  00-23  | hour of the day the cron executes(0 means midnight)                            |
+--------+---------+--------------------------------------------------------------------------------+
|day    |  01-31  | day of the month the cron executes                                            |
+--------+---------+--------------------------------------------------------------------------------+
|month  |  01-12  | month of the year the cron executes                                            |
+--------+---------+--------------------------------------------------------------------------------+
|weekday |  00-06  | day of the week the cron executes(Sunday=0, Monday=1, Tuesday=2, and so forth) |
+--------+---------+--------------------------------------------------------------------------------+
|command | Special | complete sequence of commands to execute                                      |
+--------+---------+--------------------------------------------------------------------------------+

Cron Commands



crontab filename
Install filename as your crontab file. On many systems, this command is executed simply as crontab filename (i.e., without the -a option).

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. (This option is only available on a few systems.)

PradeepKr 10Sep2010 23:28

Re: Crontab Tutorials
 
I was trying to run a script (written in PHP) using cron but I wasn't able to get some functionalities properly (which I get when I run that using browser) just because some global variables are not set.

Probably, we do not get some predefined variables ($_SERVER['']) set in cronjobs.

pradeep 13Sep2010 13:56

Re: Crontab Tutorials
 
@PradeepKr : $_SERVER is available when the script in run under Apache, not in CLI!

sneha123 10Dec2010 17:41

Re: Crontab Tutorials
 
Quote:

Originally Posted by PradeepKr (Post 72643)
I was trying to run a script (written in PHP) using cron but I wasn't able to get some functionalities properly (which I get when I run that using browser) just because some global variables are not set.

Probably, we do not get some predefined variables ($_SERVER['']) set in cronjobs.

Hello friend,,,,,sneha here,,,,I agree with you.......Thanks lot,,,,,,;);)

jacktom 4Apr2011 14:56

Re: Crontab Tutorials
 
Thanks for the note.


All times are GMT +5.5. The time now is 10:06.