Problem running PHP-Script

nnCron and nnCron LITE discussion

Problem running PHP-Script

Postby deee » Wed, 17 Jan 2007, 16:29

Hi folks

This is about nnCron LITE

I've been trying to "cron" a PHP-Script for hours now. I read all other topics about this subject, but nothing worked.

I've got the following cronjob:

Code: Select all
* * * * * "C:\Program Files\xampp\php\php-cgi.exe" "C:\Program Files\xampp\htdocs\mods\System\cronjobs\test.php"


It doesn't matter if I remove the quotes, I always get the following result in the logfile:

Code: Select all
14:26:00 2952 Start: "C:\Program Files\xampp\php\php-cgi.exe" "C:\Program Files\xampp\htdocs\mods\System\cronjobs\test.php"

14:26:00 2952 Start result: 0


If I enter exactly the same command in windows command shell, it works!

Does somebody know an appropriate solution?

Many thanks!
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 16:43

I'm pretty sure you can run this job like this:

Code: Select all
* * * * * C:\Program Files\xampp\php\php-cgi.exe C:\Program Files\xampp\htdocs\mods\System\cronjobs\test.php


Just check: if there are some _relative_ paths in test.php!
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby deee » Wed, 17 Jan 2007, 16:53

Unfortunately it does not work :(

The PHP-Script has no relatives paths
Code: Select all
<?php

file_put_contents('C:\Program Files\xampp\htdocs\mods\System\cronjobs\text.log', "test\n", FILE_APPEND);

?>
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 17:33

what is in c:\error.txt if you run

Code: Select all
* * * * * cmd /c "C:\Program Files\xampp\php\php-cgi.exe C:\Program Files\xampp\htdocs\mods\System\cronjobs\test.php" > c:\error.txt 2>&1
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby deee » Wed, 17 Jan 2007, 17:41

Code: Select all
C:\Program' is not recognized as an internal or external command,
operable program or batch file.


There is obviously a problem with the space in "Program Files"
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 17:48

somethig wrong here. i'm pretty sure the following example will load your file in notepad regardless of blank spaces:

Code: Select all
notepad.exe C:\Program Files\xampp\htdocs\mods\System\cronjobs\test.php


Does it works?
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby deee » Wed, 17 Jan 2007, 17:52

Yes, that works...but still the problem with the PHP-Script :(
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 17:59

Look at this. The first example does not work:

Code: Select all
* * * * * "c:\Program Files\Microsoft Office\Office\WINWORD.EXE C:\Program Files\Microsoft Office\Office\WDREAD9.TXT"


The second works correctly:

Code: Select all
* * * * * "c:\Program Files\Microsoft Office\Office\WINWORD.EXE" "C:\Program Files\Microsoft Office\Office\WDREAD9.TXT"


Can you test this?
Last edited by Valery_Kondakoff on Wed, 17 Jan 2007, 18:06, edited 2 times in total.
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby deee » Wed, 17 Jan 2007, 18:02

I can't see any differences between these two examples :o :)
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 18:05

Oops! Sorry, I was in a hurry and made a typo. I have edited the previous post.

BTW, the following example works correctly as well:

Code: Select all
* * * * * c:\Program Files\Microsoft Office\Office\WINWORD.EXE "C:\Program Files\Microsoft Office\Office\WDREAD9.TXT"


Does this trick works with your script?
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby deee » Wed, 17 Jan 2007, 18:10

Yes, it did...strange thing, but never mind ;)

Thanks a lot! =)
deee
 
Posts: 6
Joined: Wed, 17 Jan 2007, 16:21

Postby Valery_Kondakoff » Wed, 17 Jan 2007, 18:15

So, the idea is to leave the path to the program without quotes and to enclose the program arguments in quotes...

Like this:

Code: Select all
* * * * * path to the program "path to the file"


On my machine the following example works as well:

Code: Select all
* * * * * "path to the program" "path to the file"


The last two examples are opening program, but can not find the argument file:

Code: Select all
* * * * * path to the program path to the file
* * * * * "path to the program path to the file"
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 0 guests

cron