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?
 
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.
0
 
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
0
 
ahoffmannCommented:
what should cactiuser be in you crontab line? Are you using a proprietary crond with its own format in crontab?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ravenplCommented:
/etc/crontab allows to execute jobs as different user from root. I guess it's the username, and same suggests the log entry...
0
 
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 )
0
 
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 ...
0
 
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
0
 
sgauchoAuthor Commented:
I have to execute the PHP file in question as user  "cactiuser" and not as root. Hence the "cactiuser" before the command.
0
 
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
0
 
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
0
 
NopiusCommented:
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?
0
 
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

0
 
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.