469,338 Members | 8,424 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

how to run a script automatically?

Hi there,

I have a php script which creates a .html
gallery with thumbs and links etc..

I would like it to update the gallery
and change the thumbs according to some
random values every 60 minutes

Anyone can suggest me a way to do that?

Thx

Yang

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com

Jul 16 '05 #1
16 8536
Yang Li Ke <ya******@sympatico.ca> wrote:
Hi there,

I have a php script which creates a .html
gallery with thumbs and links etc..

I would like it to update the gallery
and change the thumbs according to some
random values every 60 minutes

Anyone can suggest me a way to do that?


I would suggest using cron/contab if you got access to it.
It will run your update script every chosen period of time

--
Daniel Kończyk
http://konczyk.net
Jul 16 '05 #2
I'll try that...

"Daniel Kończyk" <dr*******@voruta.eu.0rg> wrote in message
news:sl**********************@gnu.univ.gda.pl...
Yang Li Ke <ya******@sympatico.ca> wrote:
Hi there,

I have a php script which creates a .html
gallery with thumbs and links etc..

I would like it to update the gallery
and change the thumbs according to some
random values every 60 minutes

Anyone can suggest me a way to do that?


I would suggest using cron/contab if you got access to it.
It will run your update script every chosen period of time

--
Daniel Kończyk
http://konczyk.net

Jul 16 '05 #3
sorry, wrong post...

"Rob @ Home" <no****@nospam.com> wrote in message
news:RK*******************@rwcrnsc52.ops.asp.att.n et...
I'll try that...

"Daniel Kończyk" <dr*******@voruta.eu.0rg> wrote in message
news:sl**********************@gnu.univ.gda.pl...
Yang Li Ke <ya******@sympatico.ca> wrote:
Hi there,

I have a php script which creates a .html
gallery with thumbs and links etc..

I would like it to update the gallery
and change the thumbs according to some
random values every 60 minutes

Anyone can suggest me a way to do that?


I would suggest using cron/contab if you got access to it.
It will run your update script every chosen period of time

--
Daniel Kończyk
http://konczyk.net


Jul 16 '05 #4
is there anythingelse ?

Because I dont know how to set the chron jobs
directly from a php script, is this possible?

Yang

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com
"Daniel Kończyk" <dr*******@voruta.eu.0rg> wrote in message
news:sl**********************@gnu.univ.gda.pl...
Yang Li Ke <ya******@sympatico.ca> wrote:
Hi there,

I have a php script which creates a .html
gallery with thumbs and links etc..

I would like it to update the gallery
and change the thumbs according to some
random values every 60 minutes

Anyone can suggest me a way to do that?


I would suggest using cron/contab if you got access to it.
It will run your update script every chosen period of time

--
Daniel Kończyk
http://konczyk.net

Jul 16 '05 #5
On Tue, 9 Sep 2003 20:21:10 -0400, "Yang Li Ke"
<ya******@sympatico.ca> wrote:
is there anythingelse ?

Because I dont know how to set the chron jobs
directly from a php script, is this possible?

Yang


First, make CERTAIN the system administrator is OK with the idea!
Then all you need to do is open /etc/crontab and append the
appropriate record - it's simple text. A better approach (IMHO),
would be to set up cron to run a shell script and then have your php
code rewrite that script as required... keeping your code from
potentialy messing up a system service. ;-)>

Mike-
Mike-
Mornings: Evolution in action. Only the grumpy will survive.
-----------------------------------------------------

Please note - Due to the intense volume of spam, we have
installed site-wide spam filters at catherders.com. If
email from you bounces, try non-HTML, non-encoded,
non-attachments.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 16 '05 #6
Michael W. Cocke <co***@catherders.com> wrote in message
Then all you need to do is open /etc/crontab and append the
appropriate record - it's simple text.


While this is correct in theory - in practise you should be much more
careful. *If* the computer shuts down for any reason during this
procedure your entire cron file wil be lost. For those of us will 30
enttries in the cron file this is not good. A better way to write to a
cron is to write to file and then overwrite the existing cron witht he
new one. Like this:

$ crontab -l > /tmp/newcron.file
$ vi /tmp/newcron.file
$ crontab /tmp/newcron.file

Sylvie
Jul 16 '05 #7
On Wed, 10 Sep 2003 05:48:29 -0700, Sylvie Stone wrote:
$ crontab -l > /tmp/newcron.file
$ vi /tmp/newcron.file
$ crontab /tmp/newcron.file


surely:

$ crontab -e

does the same thing?

Cheers,
Andy
Jul 16 '05 #8
"Andy Jeffries" <ne**@andyjeffries.remove.co.uk>
surely:
$ crontab -e
does the same thing?
Andy


Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
-e edits the cron file directly creating the same senario whereby if
the computer crashes you lose your file.

Sylvie
Jul 16 '05 #9
Sylvie Stone <sy*********@canada.com> wrote:
"Andy Jeffries" <ne**@andyjeffries.remove.co.uk>
surely:
$ crontab -e
does the same thing?
Andy


Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
-e edits the cron file directly creating the same senario whereby if
the computer crashes you lose your file.


Hi Sylvie,

You are wrong, crontab -e does exactly that, copies the current crontab into
a temp file, edits the tempfile and overwrites the current crontab.

JOn
Jul 16 '05 #10
On Thu, 11 Sep 2003 04:38:43 -0700, Sylvie Stone wrote:
surely:
$ crontab -e
does the same thing?
Andy


Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
-e edits the cron file directly creating the same senario whereby if
the computer crashes you lose your file.


Sorry to be so argumentative, but you are blatently wrong!!!!

Looking the source code for crontab (vixie_cron, 3.0.1, crontab.c) reveals
that a -e switch does the following:

1)Opens the existing crontab readonly (this won't cause the loss of a
file if the computer crashes) (line 305)

2)Opens a new file called /tmp/crontab.{PID} (where PID is the Process
Identifier for the crontab process) with write access (this won't cause
the loss of the previous file if the computer crashes) (line 318/319)

3)Copies the content of the readonly original opened in step 1 to the new
temp file opened in step 2 (lines 357-359)

4)It then forks and opens the editor to edit the temp file (line 393)

5)The parent process waits for the editor to finish (line 423)

6)If all was OK with the edit, then call the replace_cmd function (line
451 calling line 491)

7)Only at this point does the real crontab file get opened for write
access and is liable to be lost if the power is lost.
However this is also the point that occurs if you just put the file on the
command line (it sets a default option of opt_replace (line 199) and sets
the filename of the incoming file to the file you specify (line 200) and
runs the replace_cmd in exactly the same manner (line 124)

So, sorry to be nasty in the first line, but that's the great thing about
Linux - it's not "I think it works this way" - it's "I know it works this
way because I've looked at the source code and it blatently does!".

Cheers,
Andy
Jul 16 '05 #11
On Thu, 11 Sep 2003 12:52:37 +0100, Jon Kraft wrote:
Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
-e edits the cron file directly creating the same senario whereby if
the computer crashes you lose your file.


Hi Sylvie,

You are wrong, crontab -e does exactly that, copies the current crontab into
a temp file, edits the tempfile and overwrites the current crontab.


Dammit Jon!!!!

I was busy looking in to the source code while you post a two line reply!
Are you trying to remove all the fun from my day ;-)

LOL!!

Cheers,

Andy
Jul 16 '05 #12
Andy Jeffries <ne**@andyjeffries.remove.co.uk> wrote:
On Thu, 11 Sep 2003 12:52:37 +0100, Jon Kraft wrote:
Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
-e edits the cron file directly creating the same senario whereby if
the computer crashes you lose your file.


Hi Sylvie,

You are wrong, crontab -e does exactly that, copies the current crontab
into a temp file, edits the tempfile and overwrites the current crontab.


Dammit Jon!!!!

I was busy looking in to the source code while you post a two line reply!
Are you trying to remove all the fun from my day ;-)

LOL!!


Well, Andy, you hopefully will be cheered up to know your thorough analysis
has entertained, educated, and, not least, brightened my day ;))

(Was I glad I'd guessed right ...)

JOn
Jul 16 '05 #13
On Thu, 11 Sep 2003 13:20:18 +0100, Jon Kraft wrote:
You are wrong, crontab -e does exactly that, copies the current crontab
into a temp file, edits the tempfile and overwrites the current crontab.
Dammit Jon!!!!

I was busy looking in to the source code while you post a two line reply!
Are you trying to remove all the fun from my day ;-)


Well, Andy, you hopefully will be cheered up to know your thorough analysis
has entertained, educated, and, not least, brightened my day ;))


I hate being wrong, so when I'm right I like to come out gloating with all
facts at my disposal.

If I had been wrong, I'd have been REAL quite on this group for a few
days....
(Was I glad I'd guessed right ...)


"guessed"? :-) Surely you meant "Was I glad I knew that" (don't worry,
I'll cover for you that it was a slip of the tongue!)

Cheers,
Andy
Jul 16 '05 #14
On 10 Sep 2003 05:48:29 -0700, sy*********@canada.com (Sylvie Stone)
wrote:
Michael W. Cocke <co***@catherders.com> wrote in message
Then all you need to do is open /etc/crontab and append the
appropriate record - it's simple text.


While this is correct in theory - in practise you should be much more
careful. *If* the computer shuts down for any reason during this
procedure your entire cron file wil be lost. For those of us will 30
enttries in the cron file this is not good. A better way to write to a
cron is to write to file and then overwrite the existing cron witht he
new one. Like this:

$ crontab -l > /tmp/newcron.file
$ vi /tmp/newcron.file
$ crontab /tmp/newcron.file

Sylvie


If you take a look at the rest of my previous message, you'll notice
that I offered a preferable method that doesn't involve writing the
crontab file directly - it depends on what the OPs exact situation is.

Mike-

Mornings: Evolution in action. Only the grumpy will survive.
-----------------------------------------------------

Please note - Due to the intense volume of spam, we have
installed site-wide spam filters at catherders.com. If
email from you bounces, try non-HTML, non-encoded,
non-attachments.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 16 '05 #15
"Andy Jeffries" <ne**@andyjeffries.remove.co.uk> wrote in message
7)Only at this point does the real crontab file get opened for write
access and is liable to be lost if the power is lost.

Hey Andy - brilliant!

I wonder if it's always work this way as I *distinctly* rememeber a
professor covering this precise topic on a HPUX 9.x server in
................ 1994 ? 1995 ?

Sylvie
Jul 16 '05 #16
On Thu, 11 Sep 2003 10:10:43 -0700, Sylvie Stone wrote:
7)Only at this point does the real crontab file get opened for write
access and is liable to be lost if the power is lost.

Hey Andy - brilliant!

I wonder if it's always work this way as I *distinctly* rememeber a
professor covering this precise topic on a HPUX 9.x server in
............... 1994 ? 1995 ?


Good question....

I would guess so as that would be the whole point of the -e switch, to
allow a safe way of editing the file, otherwise there would be no
difference in typing {editor-name-here} {cronfile}.

Unless the -e switch didn't exist in those days and therefore it was a
choice of directly editing the cron file or doing as you described.

However, I've no idea where the source would be for those files (even if
they are available).

Cheers,
Andy
Jul 16 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Spidah | last post: by
5 posts views Thread by Tim Morrison | last post: by
2 posts views Thread by Dennis | last post: by
2 posts views Thread by Efrat Regev | last post: by
11 posts views Thread by Gregor Kovač | last post: by
14 posts views Thread by asdf | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.