View Full Version : Cron Jobs: Now user accessible.
If you need CRON jobs setup, you can now submit them to the helpdesk, or set them up yourself.
Just submit a helpdesk ticket and ask that crons be enabled for your domain. We are asking that you run cron jobs no more than ONCE per hour (preferably at odd times like :05 :20 :35 :49 etc.)
Thanks
Joe
OK, "what is crontab you ask?". All crontab is - is kind of like an alarm clock. It's a TASK SCHEDULER. It's just a text file you create on your webserver (if they allow crontab - if they don't then MOVE to a REAL ISP.). The crontab file looks like this (below)
0 * * * * /etc/reset.cgi
0 0 * * * /etc/resetlogs.cgi
So what does this mean? Very simple. In this example we have a crontab file that contains 2 commands. A crontab file can have any number of commands. You put one command per line so [ 0 * * * * * /etc/reset.cgi ] is COMMAND ONE and [ 0 0 * * * /etc/resetlogs.cgi ] is COMMAND TWO. I could have COMMAND THREE - COMMAND 2,000 if I wanted to but what is important is you only put ONE COMMAND PER LINE. Also EVEN MORE IMPORTANT after the LAST COMMAND you MUST HAVE A BLANK LINE or CRONTAB WILL NOT RUN.
Ok, so let's look at each command. Here is what we have - very simple just remember this is just like setting an alarm clock. Each line or COMMAND is SCHEDULED to run at a specific time. The first 5 fields deal with setting the time the command (second field) will run.
0 * * * * is the SCHEDULE for COMMAND ONE [ /etc/reset.cgi]
0 0 * * * is the SCHEDULE for COMMAND TWO [ /etc/resetlogs.cgi]
The way the schedule looks is very cryptic but its really very simple. There are FIVE fields to the SCHEDULE
MINUTE(0-59) HOUR(0-23) DAYOFMONTH(1-31) MONTHOFYEAR(1-12) DAYOFWEEK(0-6) Note 0 = Sun
Also note that the ASTERISK (*) is what's called a WILDCARD meaning it will match any value.
Now maybe its a little clearer: The first command of our example
0 * * * * /etc/reset.cgi
Means literally "execute the script located at /etc/reset.cgi whenever the clock is equal to 0 minutes on ANYDAY, ANY HOUR,ANY DAYOFMONTH,ANY DAYOFWEEK. So the script is set to run ONCE PER HOUR EXACTLY ON THE HOUR regardless of what day it is or what hour.
Now the SECOND COMMAND
0 0 * * * /etc/resetlogs.cgi
is a little more picky. This crontab runs again whenever the internal clock hits ZERO (0) Minutes, but instead of running once per minute it will only run once per day. WHY? Because we also set the HOUR to zero so BOTH the MINUTES and HOUR must be equal to zero before crontab will execute /etc/resetlogs.cgi. So this example runs once per DAY at MIDNIGHT server time.
Now, you can get even more picky, final example lets setup a crontab to run only on Tuesday at 2:21 PM.
MIN = 21
HOUR = 14 (ah ha! note we are in a computer - only understands military time)
DAYOFMONTH = * (who cares as long as its on a Tuesday)
MONTHOFYEAR = * (again we don't care)
DAYOFWEEK = 2 (sun=0, mon=1, tue=2)
So our crontab entry would be
21 14 * * 2 /path/to/whatever/script.cgi
Herbster
06-12-2003, 04:54 PM
And for the truly dense among us... :oops:
1) Do we need to submit a ticket if we want to setup the files ourself or only if we want you to do it?
2) What do we name the file? I've seen things like cron.daily and cron.weekly mentioned here and there. Is that the correct format? cron dot whatever?
3) Where do we put it? (Be kind) Root directory?
I Googled for a tutorial on this, but didn't find anything remotely as useful as your post.
tia
You'll need to submit a helpdesk ticket, with the URL of the script you wish to run ...
ie:
http://www.domain.com/cgi-bin/awstats/inde...ex.cgi?update=1 (http://www.domain.com/cgi-bin/awstats/index.cgi?update=1)
We'll take it from there.
Joe
Herbster
06-12-2003, 09:21 PM
Thanks Joe, but I was hoping to set up a crontab as per your instructions and retain control of it. I'll need to do some fine tuning at first and changes/additions as I add new features to the site. Different tasks need to run at different times, so one script won't handle it all.
Were you being helpful by offering to set it up, or is that the only way it can be done?
Right now, until I find time to re-code the one that broke after Ensim <ahem>"upgraded"</ahem> - thats the only way.
Herbster
06-13-2003, 12:32 AM
OK. I'll try to hold my water until then.
Thanks.
Herbster
06-21-2003, 10:56 PM
*bump*
Herbster
07-01-2003, 02:37 PM
Back again. :P
Yeah. I know. Nag. Nag. Nag. :roll:
Powered by vBulletin™ Version 4.0.3 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.