How to run a php script every our automatic.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to run a php script every our automatic.

Postby statiic » 24. February 2005 11:05

I heard that i could run an php script every hour with windows task manager. Now i cant figure out how this works.

I should set an time an a link like.

C:\apachefriends\xampp\php\php.exe C:\script.php


But it doesnt seem to work. Deos anyone has any idea's .

Should be the same like cronjobs in linux.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Wiedmann » 24. February 2005 11:10

Your script is working from the command line?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby statiic » 24. February 2005 11:13

No it is not working. And it should be working.


I want to run an script every hour. I can do this with task manager, but i dont know how.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Wiedmann » 24. February 2005 11:15

No it is not working.

Why?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby statiic » 24. February 2005 11:34

If i knew why it isnt working. Then i wasnt it asking here.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Ceelight » 24. February 2005 11:39

Of course it's not working. You can't execute a php-skript on the command line. It must be parsed by the php-parser. That means you have to open it in your browser like http://localhost/script.php. XAMPP must be running, but that should be clear...

@Wiedmann ;)
There's no place like 127.0.0.1
User avatar
Ceelight
 
Posts: 295
Joined: 31. January 2004 19:57
Location: Pfälzer im niedersächsischen Exil ;-)

Postby Wiedmann » 24. February 2005 11:45

You can't execute a php-skript on the command line.

Sorry Ceelight, that's not true. You can use PHP at the command line, of course. See the XAMPP installer.

If i knew why it isnt working. Then i wasnt it asking here.

Right, but if the script doesn't work, there must be an error message or a false behavior. You have enabled a correct error_reporting?

Without more infos from you, i only can say: scripts does work at the command line or task scheduler.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby statiic » 24. February 2005 11:49

No there are no errors in the script. Because when i run the script normally it works.

But i need to know what exact line i have to use to run the php script.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Wiedmann » 24. February 2005 11:56

Because when i run the script normally it works.

That's not interessting here that the script work "normally" (through a webserver)... (PHP-CLI is not CGI or SAPI)

But i need to know what exact line i have to use to run the php script.

Your command is correct.
Code: Select all
C:\apachefriends\xampp\php\php.exe C:\script.php
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby statiic » 24. February 2005 12:05

Ok now i have made an .batr file with the exact same command line and it seems to work. Only now i have another problem.

I'm including a few scripts where i set my db connection and the pass etc..

Now the scripts says it couldnt find the db settings. How the hell is this possible. When i run the script normally it works perfect.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Wiedmann » 24. February 2005 12:21

I'm confused... You say, the above command doesn't work at the command prompt, but in a batchfile it does?

Now the scripts says it couldnt find the db settings

The path for the include is not correct?

Don't you really have a correct and complete error message?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby statiic » 24. February 2005 12:27

haha no sry. Because the server is at my parents home. And i was giving my little brother commands to do this all.

But he is to school now.

But he has also quite a knowledge of php an he said that it couldnt find the db script. But the link is correct, because when i run the script normally it works fine.

So is it possible that it cant include any scripts , because of the external link to it.
statiic
 
Posts: 12
Joined: 20. November 2004 12:33

Postby Ceelight » 24. February 2005 13:37

Wiedmann wrote:
You can't execute a php-skript on the command line.

Sorry Ceelight, that's not true. You can use PHP at the command line, of course. See the XAMPP installer.


:oops:
Sorry, didn't know that.
There's no place like 127.0.0.1
User avatar
Ceelight
 
Posts: 295
Joined: 31. January 2004 19:57
Location: Pfälzer im niedersächsischen Exil ;-)


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 66 guests