Gossamer Forum
Home : Products : DBMan : Customization :

Auto adding one every Saturday at 12 am?

Quote Reply
Auto adding one every Saturday at 12 am?
Sorry for the confusing headline... I created a db at http://3horseranch.netfirms.com/cgi-bin/dbman/db.cgi. I created it to keep track of "horses" as part of a game. One of the fields is "Age". In the game, all "horses" age 1 "year" every Saturday at midnight (Eastern Time). I'd like to know if there's anyway for my db to automatically add a year to thier age Saturdays at 12 am ET. Actually, it would be Sunday then... Any way to do this?
Quote Reply
Re: [thebuckskinappy] Auto adding one every Saturday at 12 am? In reply to
you will need to run cron on your host server

maybe someone more familiar with cron can help.

Code:

Minutes Hours Day of Month Month Day of Week

0-59 0-23 1-31 1-12 0-6



I've never done it but looks like this would work.
0 0 * * 6 /path_to/changeage.cgi

I've attached a file that came from the monthcool mod in Links 2 - it was used to reset the monthly hits field to zero. I did a little testing and it seems to work as intended. you will need to set the paths and the field number of the age field.

Put it in a protected folder.

You will want to run this first on a backup copy.

Then make a backup copy of the database before actually running it the first time.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Auto adding one every Saturday at 12 am? In reply to
I'm really new to this kind of scripting, I've mostly just dabbled in HTML before, where would I put this to make it work?
Quote Reply
Re: [thebuckskinappy] Auto adding one every Saturday at 12 am? In reply to
well, it is not html. the file is perl - kinda like the db.cgi file

you will need to change the following lines:


Code:
require "/path_to/cgi-bin/links/admin/default.cfg"; # Change this to the path to your default.cfg
require "/path_to/db.cgi";

$db_links_name = "/path_to/default.db"; # PATH to default database.

# change the 10 to the appropriate field number in db_def section of
# the default.cfg file.
$RecOut[10]++;



send your host an email and inquire about running a cron job. If they don't allow it, you will probably need to run the file manually. The only way I know to automatically launch a file/program/event like what you want is to use cron.

you should test it first by using a back up copy of your database.

BACK UP YOUR ORIGINAL DATABASE FILE BEFORE RUNNING IT.


If this is still confusing, maybe some of the dbman experts can help you enter it into your db.cgi file so you can run it (manually) as a menu item.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Auto adding one every Saturday at 12 am? In reply to
There's also a script called Fake Cron if your host won't let you use a real one. Wink