Jump to content

I'm trying to create a CronJob to update a database table.


Recommended Posts

I'm attempting to customize a script but so far haven't had any luck.  As a possible work around I thought I would create a Cron Job that would automatically upload a new record into a specific table on my MySQL database at night.  But I'm not sure how to do this.  I was wondering if anyone could provide me with the syntax of:

 

1) The cron job itself.  I of course have to fill in the server/database/table specific information but I don't have any a clue where to start.

2) How should I format the .sql file (or whatever) so that it goes into the database correctly where it's supposed to and doesn't screw anything up?

 

Here are two screen shots showing the structure and browse (from phpMyAdmin) of the specific table in the database I want to edit.

 

structureqd7.jpg

 

browsecg8.jpg

 

 

If necessary at all here are some details:

server: localhost

table: comikaze_news

 

I really, super, duper, insanely appreciate it guys!

The script itself handles uploading/posting/navigation for a comic and related news post.  I'm basically trying to get it to do more then what it was designed for.  In this thread I wasn't exactly looking for help on the script (though I'd be happy to have it), instead I'm looking to work around the script by creating a cron job that will insert data into a table of an existing database.  I hope that makes some sense.

 

If it helps at all, here's some server info:

MySQL: 4.1.20-1.RHEL4.1

PHP: 4.3.9-3.22

Apache: 2.57-centos4.2.build81061129.22

Yeah, but you're asking about insert/update statements....

Ah, okay that sounds familiar! (My php/mysql experience is limited to reverse engineering the scripts that make my site run).  So I guess what I'm looking for is what's the syntax I'd use for a cron job to insert/update the tables database?  I imagine I'd have to load the applicable data into a file (csv?) and stick it somewhere on the server.

Read the following page: http://www.ss64.com/bash/crontab.html

Thanks Bubblegum, I'll take a look at it and see what I can glean from it.  It really seems like what I'm trying to accomplish should be easy, but like I said, my experience with coding is limited so it's all new stuff to me.

 

toasty, you should consider making time_posted a unix timestamp.... that way you can manipulate it and put it in any form you like

If I knew how to rewrite the code I would.  Initially when the script would output the datestamp for the news posts (which is what I'll be importing with the cron job if I can get it to work) it was coded to print out YYYY-MM-DD.  It took me forever and a ton of forum posts to figure out how to get it do print it out in the Unix format I wanted.

 

Here's the site that all this coding and customization is going towards.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.