[thelist] sleep, etc to make a script not take resources
Bob Meetin
bobm at dottedi.biz
Tue Oct 13 14:21:34 CDT 2009
Hassan Schroeder wrote:
> 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. :-)
>
> FWIW,
>
my scripting skills are limited to PHP and shell scripts (mostly
#!/bin/sh); learning perl just isn't going to happen (thx Anthony) any
time soon.
maybe it is trivial but this server is already stressed for whatever
reasons; as I have been regularly submitting complaints using their
ticket system I need to make sure that no eventful roads lead back to
me. a couple times they have replied to my requests that they found
some account doing some god-awful thing and suspended it. if you live
in a glass house, well you get the picture.
will inserting a sleep in the script actually do anything? or if they
are investigating problems will the sleep which would extend the running
time simply appear to them as an unknown and bring em on? if it runs
and completes in 10 seconds it probably isn't worth bothering.
door #3 - yes doable but I'd prefer to avoid local processing because
that makes it slightly more complicated to automate this application
which will likely require downloading a data file weekly.
More information about the thelist
mailing list