Cron Jobs and PHP

Status
Not open for further replies.

bluled

New Member
Messages
3
Reaction score
0
Points
0
First of all.. my server is Starka
I want to launch a PHP page once a Day
I tried a lot of strings on Cron Jobs, but i can't execute the page.
I think i can't see the PHP executable


Look at some mail that i received (at the moment,the file download.php is in my home directory and have a copy in public_html directory) :
/bin/sh: /usr/bin/php -q /home/bluled/www/download.php: No such file or directory

/bin/sh: php -q /home/bluled/public_html/
download.php: No such file or directory

/bin/sh: php /home/bluled/download.php: No such file or directory

/bin/sh: /usr/bin/php -h: No such file or directory <--------

/bin/sh: /usr/local/bin/php -h: No such file or directory <---------

/bin/sh: php -h: command not found

/bin/sh: php-cron /home/bluled/download.php: No such file or directory

Then i tried to execute directly the file using the command /home/bluled/public_html/
download.php:

Before setting executing permissions:
/bin/sh: /home/bluled/public_html/
download.php: Permission denied

After setting executing permissions:
/home/bluled/public_html/
download.php: line 1: ?
: No such file or directory
/home/bluled/public_html/download.php: line 2:
: command not found
/home/bluled/public_html/download.php: line 3: =: command not found
/home/bluled/public_html/download.php: line 3: //define: No such file or directory
/home/bluled/public_html/download.php: line 4: =: command not found

Then i added "#!/usr/bin/php" at the top of the file and now i don't receive any mail, and the job doesn't start.

I think that there isn't any php file in /usr/bin/ or /usr/local/bin/ or i haven't the permission to see it.

Can anyone help me??

(I'm sorry for my english)
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Did you try

Code:
#!/usr/local/bin/php

as your shebang?
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Yes, i did.. but it doesn't work..

Do you know if "/usr/bin/php -h" or "/usr/local/bin/php -h" normally work?

I don't use cron normally, but I thought I had it working for others before using that shebang.
 

descalzo

Grim Squeaker
Community Support
Messages
9,372
Reaction score
326
Points
83
I run:

Code:
/usr/local/bin/php -q   /home/username/www/cron.php

No quotes.
cron.php does not have a shebang line.
Permissions set to 644

And it runs fine.
On chopin.

I have no idea why some people cannot run cron jobs. They seem to try every combination, but it does not work. If they do get it to work, they don't bother to come back and tell us how they got it to run. It may be one server. I have no idea.
 

bluled

New Member
Messages
3
Reaction score
0
Points
0
I run:

Code:
/usr/local/bin/php -q   /home/username/www/cron.php
No quotes.
cron.php does not have a shebang line.
Permissions set to 644

And it runs fine.
On chopin.

I have no idea why some people cannot run cron jobs. They seem to try every combination, but it does not work. If they do get it to work, they don't bother to come back and tell us how they got it to run. It may be one server. I have no idea.


The first error is that i was using " character, because i read somewhere in this forum to use them.
After removing quotes, some combinations like /home/bluled/public_html/1.php (with shebang) or /usr/bin/php -q '/home/bluled/www/1.php don't send any error to e-mail, but i think they don't do anything anyway .

I solved temporarily the problem using
wget -q http://peruch.x10hosting.com/download.php
when i'll have more time i'll make more attempts
 
Status
Not open for further replies.
Top