Jump to content

Archived

This topic is now archived and is closed to further replies.

All4172

Crontab and PHP script

Recommended Posts

I'm able to run the file fine through the browser, but it doesn't seem to be able to be executed by the crontab.  I end up getting:

/home/path/public_html/list.php: line 1: ?php: No such file or directory
/home/path/public_html/list.php: line 3: syntax error near unexpected token `('
/home/path/public_htmllist.php: line 3: `if ($handle = opendir('/home/empirer1/public_html/marketwire')) {'

I've double and triple checked the path (copied the path out of the file in fact).  Any ideas?

Share this post


Link to post
Share on other sites
i had this problem too.  it's running from the shell (if i remember the problem correctly), so you need to add a line to tell it to use php to parse the file.  the line i used was:

[code]#!/usr/bin/php -q[/code]

add that to the top of the file and give it a whirl.  the path might need to be changed.

Share this post


Link to post
Share on other sites
Ok thanks.  Add that to the top of the PHP file?  Like:

[code]
#!/usr/bin/php -q
<?php
code.....
[/code]

Share this post


Link to post
Share on other sites
Any idea how to make it works with something like script.cgi?login=1&un=2........

I found this php script but the cron tab returns a "This program can only be run through a web server." when it runs.  Although when running it through a browser it works.

[code]
#!/usr/bin/php -q
<?PHP
    putenv('QUERY_STRING=login=1&id=100&pw=admin100');
    passthru("/home/path/public_html/cgi-bin/exec/admin.cgi");
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.