Closed Thread Icon

Preserved Topic: Pre Schedualling Tasks... Pages that link to <a href="https://ozoneasylum.com/backlink?for=21034" title="Pages that link to Preserved Topic: Pre Schedualling Tasks..." rel="nofollow" >Preserved Topic: Pre Schedualling Tasks...\

 
Author Thread
WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-29-2002 21:09

I am going to be selling my joke site and one of the stipulations of the sale is that I code up a joke pre-schedualing script. So that the new owner would be able to enter in say 100 different jokes and titles and then it adds a given number to the database per day.

The site is done with PHP/MySQL right now. But I don't think PHP has this ability. I think I could do it with a perl script running on the host machine. But I am not really sure where to begin with this one.

Any ideas?

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 06-29-2002 21:49

Hi WarMage,

What part did you need ideas on, the scheduling or the script itself? If you're on a unix server you can code the script and use crontab to schedule it to run as a nightly cron job. You might even be able to code it in PHP and use lynx to run the script as a cron job. You will need to do a little research on that though. I've only used perl and shell scripts for cron jobs. I hope that gives you a start at least!

Regards,
Charlie

[This message has been edited by Piper (edited 06-29-2002).]

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-29-2002 22:15

So you recommend perl?

The way I was thinking would be to have a perl script run in the background.

It would sleep for a minute then check the time. If the time was right it would execute a URL which would execute the PHP script.

I am just not sure if this would be a good way of doing it.

Since I am selling the site, I really don't have access to the person's server so I am trying to get the theory down so when I send it over it just works, one he follows the instructions I give him.

Basically I would have him type

&perl timedUpdate.pl

into his command line and the script should take care of the rest?

Or can I do it with PHP only?

Ugh, I hate feeling like I am in over my head.

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 06-30-2002 00:00
quote:
So you recommend perl?


only because that's what I know best, not necessarily because it would work best in this instance.

quote:
The way I was thinking would be to have a perl script run in the background.


I think that will put a lot on unneeded overhead on the server. Then again, I'm just anal about seeing processes sitting idle in the background.

If the person has access to SSH/telnet like you mention, I would really look into setting it up as a cronjob that runs every night, say at midnight. If you get the script coded in PHP, I think you can set the cron job up so that lynx can execute the script for you. I will go and see if I can find info on PHP cronjobs. I remember reading about it somewhere, just can't remember where.


~Charlie

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-30-2002 00:02

Yeah, that is the ticket. I am not really sure how to work with Crons... I will look it up too. Thanks for the information on that.

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 06-30-2002 00:19

OK, I think I found it.

Try this: http://www.php.net/manual/en/intro-whatcando.php
and this: http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=195657;search_string=cron%20php;#195657

The second bullet down in the first link talks about command line scripting. If you can get the script working from the command line then your home free. The second link talks about using lynx to run the script. Setting up a cron job is pretty easy once you find out the syntax. There are tons of tutorials out there for you but let me know if you come up empty handed or have any questions about it.

Good Luck!
~Charlie

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-30-2002 04:56

How would I use lynx to access a webpage behind a .htpasswd? This if for the crontab...

0 0 * * * /usr/local/bin/lynx "URL"

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-30-2002 05:12

Had I been smart I would have looked at the man pages for Lynx first... the -auth switch would have been the easy answer.

0 0 * * * /usr/local/bin/lynx -auth=USERNAME:PASSWORD "URL"

Look correct to those who are in here?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-30-2002 06:10

Mage -

We did a content management system for a client that kinda does this. Basically, we can enter information into the database (in this case, articles), and set them for a release on a specific time. This allows us to stack articles for, say, a holiday weekend.

All we did was set an ONLINE date. Normally, this is the date that the article was released to the public. The query that displays the article list only displays articles whos release time/date has passed. If the time/date is in the future, they are not displayed.

Is that similar to what you need? Ours was all PHP/MySQL, and has proven VERY reliable.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-30-2002 14:10

Now, that would work as well...

I am sort of doing that now with pictures, setting certain ones to display on holidays so to customize the site...

There would be many ways to go about doing this.

Thanks for the input pugzly.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-30-2002 19:00

I used two of the above solutions:

First, I tried the lynx crontab which worked. There were no problems with this one. Once you get the syntax correct there are no problems. I had lynx access a script that would automatically push one joke off of the queed table and put it into the active table at an interval determined by the crontab.

Second, I went with Pugzly's idea of working it right into the database. This was done by adding an extra column and placing a time_stamp into it. Working directly with php I would take in user input of month day and year and use mktime() to construct the time element based on the user input and place it into the database.

The next part was the trick, in all of my SQL functions which print the information out to the user I added a WHERE clause which said time < $time where $time = time();

The PHP/MySQL solution worked perfectly without me needing to rely on other technologies (such as lynx), which makes it much easier to transfer to the buyer.

Thanks for all the help Piper and Pugzly you really made my life easier.

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 07-01-2002 05:16

I like Pugzly's idea much better. That just sounds much easier to implement and a lot less operator involvement from the new owner. I'm glad you got it working.

Regards,
Charlie

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-01-2002 18:38

Not much to add here except my way (which may or may not be the right way )

Pugz solution is great I've used it for publishing with straight PHP as well. However for other timed tasks I tend to use Piper's solution. I've found perl to be much easier to task with server side tasks using a combo of that with cron. I usually just use PHP for web generation.



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu