Problem setting up cron job

I am having minor issue setting up a cron job.

Code:
crontab -u cacti -e */5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
Ambiguous output redirect.

For this reason, cacti does not work properly. I am not sure what the issue is or how to fix it.

Thanks for the help.
 
jonfr said:
I am having minor issue setting up a cron job.

Code:
crontab -u cacti -e */5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
Ambiguous output redirect.

For this reason, cacti does not work properly. I am not sure what the issue is or how to fix it.
Quite frankly I'm not even sure what your issue actually is. First off: if you use that as a commandline, so including all the asterisks and such, then I can imagine that it won't work properly. The right approach would be to use # crontab -u cacti -e after which you can add the appropriate line in the editor. For more details on how to use the crontab command check out it's manualpage: crontab(1).

Based on what you shared above you could use this:

Code:
*/5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php
That should result in poller.php getting executed every 5 minutes. And if it doesn't then you should get plenty of usable output in the mailbox of the cacti user.
 
Thanks. The command was from the cacti install guide. It looks like this as I got it.

Code:
5. Add the line to cron jobs with the command:
# crontab -u cacti -e 
*/5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
 
Well, the problem with that line should be obvious: because it re-directs both stdout as well as stderr this command will never create any output what so ever. So if this script isn't doing what it's supposed to do then you won't easily find out about it (unless it also uses facilities such as syslog).

As such my advice would be to remove the redirections so that you can check the output generated by the PHP script, that should give you a good idea as to what is going wrong.
 
If cron(8) gets any output, it mails it to the user. Scripts that aren't meant to produce text output often try to eliminate all output like this to avoid nuisance mail ("job ran! job ran! bucaww! job ran!"). Presumably poller.php does something that doesn't produce text output, and if it has errors, shows them elsewhere.

You're right, the main error is pasting those two lines as one command. It's a command that starts the editor, and then a separate line to enter in the editor.
 
I got it to work with webmin. I did just input the command into webmin and set-up it to run every 5 minute. Now I just have to configure it properly and hope it works.

Thanks for the help.
 
ShelLuser said:
As such my advice would be to remove the redirections so that you can check the output generated by the PHP script, that should give you a good idea as to what is going wrong.

poller.php runs to collect statistics into a sqlite database. In general it should not write to STDOUT/STDERR.
 
jonfr said:
I got it to work with webmin. I did just input the command into webmin and set-up it to run every 5 minute. Now I just have to configure it properly and hope it works.
Be very careful with webmin in combination with FreeBSD, very careful.

It works, but it doesn't fully support FreeBSD, it's by far comparable to what you get when used on Linux. Some modules (for example support for the ipfilter firewall) are plain out broken whereas others have a wrong default configuration.

As such my warning. Although it's perfectly usable on FreeBSD (all my servers use it as well) it has several flaws, so don't blindly trust whatever it tells you.
 
Back
Top