Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-15-2003, 10:23 PM   #1
Board Voyeur
Confirmed User
 
Join Date: Aug 2003
Posts: 130
An actual serious question

How do i set up a cron to run a script every 12 hours?

I think i have root server access is it possible for me to do it or should i just bug the shit outta my host?
Board Voyeur is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-15-2003, 10:29 PM   #2
m4tt
So Fucking Banned
 
Join Date: May 2003
Location: San Diaygo, CA
Posts: 384
you are posting too much.. get off the meth

root> crontab -e

* 12 * * * /usr/lib/php /path/to/script

something like that.. i've been drinking

edit: ps, search google.. it's a wonderful tool
m4tt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-15-2003, 11:51 PM   #3
AOJ Brian
Confirmed User
 
Join Date: Apr 2003
Posts: 257
Quote:
Originally posted by Board Voyeur
How do i set up a cron to run a script every 12 hours?

I think i have root server access is it possible for me to do it or should i just bug the shit outta my host?
I'd just drop your host an email. Keep em on their toes! ;)

Brian
AOJ Brian is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-15-2003, 11:52 PM   #4
SYNIKAL
Confirmed User
 
Join Date: Feb 2003
Posts: 1,795
Quote:
I think i have root server access

you think?
__________________
...........
SYNIKAL is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-16-2003, 01:39 PM   #5
Burnie
Confirmed User
 
Join Date: Nov 2002
Location: Hurricane Florida
Posts: 205
How to run automatic schedule with CronTab. Here are the settings (change it to your path information):

0 6 * * 1 /path/to/whatever/script.cgi
0 6 * * 2 /path/to/whatever/script.cgi
0 6 * * 3 /path/to/whatever/script.cgi
0 6 * * 4 /path/to/whatever/script.cgi
0 6 * * 5 /path/to/whatever/script.cgi

The above example will run The Script Monday through Friday at 6 am. If you want it to run at 6 am every day you only need one line:

0 6 * * * /path/to/whatever/script.cgi

For those of you that need more information on this read below:

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 * * * * /path/to/whatever/script.cgi
0 0 * * * /path/to/whatever/script.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 * * * * * /path/to/whatever/script.cgi] is COMMAND ONE and [ 0 0 * * * /path/to/whatever/script.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 [ /path/to/whatever/script.cgi]

0 0 * * * is the SCHEDULE for COMMAND TWO [ /path/to/whatever/script.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 * * * * /path/to/whatever/script.cgi

Means literally "execute the script located at /path/to/whatever/script.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 * * * /path/to/whatever/script.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 hour. WHY? Because we also set the HOUR to zero so BOTH the MINUTES and HOUR must be equal to zero before crontab will execute /path/to/whatever/script.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

UPLOADING AND EXECUTING CRONTAB(s)

It does not matter what you call your crontab file. You should name it something so you remember what the file is (eg: cronstats or croncgi) or whatever.

Upload as ASCII file (they are text files) all text files are ASCII

When you are done with all that telnet into your server and run the crontab file by going to the directory containing the crontab file (again - it makes no difference where you put the crontab file). I would suggest making a special hidden directory or using a directory inside your cgi-bin so nobody can see it. So to finish and execute your crontab file just telnet into your server and type:

cd /path/to/crontab/directory
crontab nameofcrontabfile

then to view it type

crontab -l (thats an L not a 1)

Or you can use Pico, this is a unix text editor like notepad is in windows. It has a help file to help you use it. Note: ^ is = to "ctrl" I modify mine directly on the server with pico because I had problems doing it here and then uploading it.

I hope this helps everyone that does not understand crontab.

Regards
Burnie
Burnie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-16-2003, 01:44 PM   #6
Carrie
Confirmed User
 
Join Date: Apr 2002
Location: Virgin - nee
Posts: 3,162
Nice copy/paste.
Carrie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-16-2003, 02:03 PM   #7
Burnie
Confirmed User
 
Join Date: Nov 2002
Location: Hurricane Florida
Posts: 205
Copy/Paste today - YES

But I typed it up last summer to help out someone else trying to use Crontab.

My
Burnie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.