Problems with CRON

Hi,

I have inserted the following line in my crontab:

*/5 * * * * cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php

The CROND is running fine and /var/log/cron shows clearly that the cron is being executed:

Apr 26 12:00:01 NagiosWCMPTSI crond[23048]: (cactiuser) CMD (cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php )

However, nothing is being generated i.e. the cron is not being executed..

Why is this so ? whats wrong with my crontab ?

thnx
sgauchoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ravenplCommented:
Is the php file executeable (has execute bit set?)
Is the first line of php file like:
#!/usr/bin/php-cli
or
#!/usr/bin/php -q
ahoffmannCommented:
what should cactiuser be in you crontab line? Are you using a proprietary crond with its own format in crontab?
ravenplCommented:
/etc/crontab allows to execute jobs as different user from root. I guess it's the username, and same suggests the log entry...
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

ravenplCommented:
In fact I am wrong in my previous comment.
Yes, author, You have to remove the 'cactiuser' entry, as cron tries evaluate this as command to run
CMD (cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php )
ahoffmannCommented:
hmm, that's what I guess, but have tooooo often seen people running propritary software and I got bashed for the standard answer :-/ hence my deliberated question ...
biraCommented:
generate an error log by redirection output to find what
is going on:

cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php 2> /tmp/catiuser_error.log
sgauchoAuthor Commented:
I have to execute the PHP file in question as user  "cactiuser" and not as root. Hence the "cactiuser" before the command.
ravenplCommented:
> Apr 26 12:00:01 NagiosWCMPTSI crond[23048]: (cactiuser) CMD (cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php )
It says it's executing the command as cactiuser ...

Have You creted the crontab entry as cactiuser or root? In the first case cron handles it automatically, otherwise add exactly same entry as You already did to the /etc/crontab
ahoffmannCommented:
I guess a standard cron where the last command has to follow the time fields in the crontab, in the given example "cactiuser" seems to be obsolete
TintinCommented:
/etc/crontab is part of vixie-cron found on pretty much all Linux distributions.

There's so many ways to define a cronjob on a Linux box (in fact, it can be damm confusing trying to find all the cronjobs).

The format for /etc/crontab is:

cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php 2> /tmp/catiuser_error.log

times user command

Try changing the cronjob to:

*/5 * * * * cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php >/tmp/cactiuser 2>&1

Then look in /tmp/cactiuser after it has run.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Artysystem administratorCommented:
sgaucho:
1) what is your OS: uname -a
2) did you read 'man crontab'?
3) where is your crontab is located? It can be either in /etc/crontab, /var/spool/cron or in some other places. Crontab format is different for that different locations.
4) how do you get use of your crontab? You just edit /etc/crontab  or edit some other /tmp/crontab and excute 'crontab' command? If you are running 'crontab' from which user?
sgauchoAuthor Commented:
Solved it...

as root, I edited /etc/crontab and inserted the line :
*/5 * * * * cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php
but this didnt work

as cactiuser i did the same as above but even this didnt work..

I create a cron file in /etc/cron.d and inserted the line:
*/5 * * * * cactiuser /opt/lampp/bin/php /opt/lampp/htdocs/cacti/poller.php

and voila its executing fine.. can anyone please explain this ?

My OS is Linux CENTOS 4

TIA,
sg

TintinCommented:
That's very strange.

It should be working just fine from /etc/crontab.  My only thought is it could be environment.  The default /etc/crontab has:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/


set in it.  This may cause your script to fail.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.