[SOLVED] bash# ./poller.php ... ?php: No such file or direct

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
jamberbamber
Posts: 10
Joined: Thu Feb 14, 2008 1:38 am
Location: SF Bay, California

[SOLVED] bash# ./poller.php ... ?php: No such file or direct

Post by jamberbamber »

Hello, I cannot get the poller.php script to run via crontab (crontab is configured properly.) When I run it by hand, I get the error message below:

Code: Select all

[root@nagios01 cacti]# ./poller.php
./poller.php: line 1: ?php: No such file or directory
./poller.php: line 2: /bin: is a directory
./poller.php: line 3: +-------------------------------------------------------------------------+: command not found
./poller.php: line 4: syntax error near unexpected token `|'
./poller.php: line 4: ` | Copyright (C) 2004-2007 The Cacti Group                                 |'
[root@nagios01 cacti]#
When I run:

Code: Select all

php -q /path/to/poller.php 
it populates the rra/ directory as expected (whlie running as cactiuser or root.) The crontab job is setup under cactiuser. Permissions are set properly, with cactiuser owner of rra/ and log/ folders and having read/write (and more) access. /var/log/cron shows that the job is executing normally.

OS: Redhat 4.6 32-bit. Cacti and rrd complied from source. Used pre-installed rpms for httpd, php, php-mysql, php-snmp, mysql, mysql-server, and net-snmp.

I've searched the forums and see many similar posts, but so far can't seem to find a solution. Any ideas? Thanks everyone.

Justin
Last edited by jamberbamber on Fri Feb 15, 2008 12:01 am, edited 1 time in total.
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Hi

you need to run it with "php poller.php".

Does your crontab entry look like that ?

Code: Select all

*/5 * * * * /usr/bin/php /home/cactiuser/cacti/poller.php > /dev/null 2>&1
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
jamberbamber
Posts: 10
Joined: Thu Feb 14, 2008 1:38 am
Location: SF Bay, California

Post by jamberbamber »

Hi, thanks for the reply. I've tried both of these commands in crontab:

Code: Select all

*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
and this:

Code: Select all

*/5 * * * * cactiuser /usr/bin/php -q /var/www/html/cacti/poller.php > /dev/nul                                             l 2>&1
My permissions are as such:

Code: Select all

drwxrwxrwx  2 cactiuser root   4096 Nov 17 10:11 log
-rwxrwxrwx  1 apache    root   2451 Nov 17 10:11 logout.php
-rw-r--r--  1 root      root   7294 Feb 11 17:10 multiple_vulnerabilities-0.8.7a.patch
-rwxrwxrwx  1 apache    root   4306 Nov 17 10:11 poller_commands.php
-rwxrwxrwx  1 apache    root   2243 Nov 17 10:11 poller_export.php
-rwxrwxrwx  1 apache    root  14960 Nov 17 10:11 poller.php
-rwxrwxrwx  1 apache    root     71 Nov 17 10:11 README
drwxrwxrwx  5 apache    root   4096 Nov 17 10:11 resource
drwxrwxrwx  2 cactiuser root   4096 Feb 13 21:27 rra
jamberbamber
Posts: 10
Joined: Thu Feb 14, 2008 1:38 am
Location: SF Bay, California

Post by jamberbamber »

Here's the output from /var/log/cron:

Code: Select all

Feb 14 20:55:01 localhost crond[27150]: (cactiuser) CMD (cactiuser /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1)
jamberbamber
Posts: 10
Joined: Thu Feb 14, 2008 1:38 am
Location: SF Bay, California

Post by jamberbamber »

Ahh, I see that it was my error by specifiying the username in the command. :oops: Thanks for pointing that out to me!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests