[thelist] sleep, etc to make a script not take resources

Hassan Schroeder hassan.schroeder at gmail.com
Tue Oct 13 13:46:19 CDT 2009

On Tue, Oct 13, 2009 at 11:18 AM, Bob Meetin <bobm at dottedi.biz> wrote:
> This might seem like a silly question, but ...   I have a script that I
> will need to run against 30,000 lines or so in a text file (.csv).  It
> will need to do some pattern matching, then if it matches insert an
> entry into a database field.
> I can do this using either  a PHP or shell script.  What is a smart way
> of running it so that it doesn't toast the CPU and draw the gods upon
> me? Can you interject a "sleep 1" or something else into the script or
> does that even help?

I wouldn't think running such a script would last long enough to
bother anyone, frankly. 30k lines is pretty trivial.

> door #2 says that I set up PHP/MySQL locally, run the app, and upload
> the database file rather than runnning the program on the webhost server.

door #3: Since the regular expression comparison is by far the most
computationally intensive part of this, parse the CSV file locally and
generate a script of insert statements; upload that, run on DB server.

In a loop with sleep()s included, if it makes you feel better. :-)

Hassan Schroeder ------------------------ hassan.schroeder at gmail.com
twitter: @hassan

More information about the thelist mailing list