Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I create my system graphs in rrd using perl script. When I run the script manually it'll update the graphs. On the other hand cron shows in logs that the job has been executed but it does not update graphs.. Any help please?

I've set apache2 directory permission root:apache with 770

Distro: CentOs 5.5.

Cron Config:

0,5,10,15,20,25,30,35,40,45,50,55 * * * *       /home/user/graphs/script-rrd.pl  > /dev/null 2>&1

I've already check /var/log/cron it shows that the above script has been executed but it does not update graphs in /var/html/www/graphs.png

Resolution of this issue:

cp -rf /opt/rrdtool-1.4.4/lib/perl/5.8.8/i386-linux-thread-multi/* /usr/lib/perl/site_perl

after copying rrd stuff in /usr/lib/perl5/site_perl issue has been resolved.

I've already created PERL5LIB. After creating PERL5LIB i was able to run scripts manually but it was not being run by cron so that is why i've to copied files as the above.

SELINUX is as following: SELINUX=disabled SELINUXTYPE=targeted SETLOCALDEFS=0

share|improve this question
    
Have you tried removing the output redirection, and setting the /etc/aliases such that the output will be emailed to you? –  wolfgangsz Sep 16 '10 at 23:50
1  
*/5 * * * * command would be easier to write... –  Chris S Sep 18 '10 at 0:12

6 Answers 6

This looks very much like like a SELinux denial.

share|improve this answer

There's an obvious mistake in your cron line: you redirect error output to /dev/null. Don't do this, and look at your mail to see what went wrong.

A common problem with cron jobs is that they get a very limited environment: your .profile is not read. You may need to define some environment variables for your script to run.

ADDED: You did:

cp -rf /opt/rrdtool-1.4.4/lib/perl/5.8.8/i386-linux-thread-multi/* /usr/lib/perl/site_perl

Bad idea! You should not put your own files in /usr (outside /usr/local). That area is reserved to the package manager. Sure, it's easy now, but you will run into trouble tomorrow (for example when you upgrade rrdtool), and it'll be hard to debug then.

Instead, do what people have been recommending and define the necessary environment variables in your script (or source ~/.profile); you need PERL5LIB (and perhaps others).

share|improve this answer

Not related, but you can replace 00,05,10,15 .. etc with */5 instead :-)

share|improve this answer

crontab does not know vars that your shell would since it runs shellless. So if you run commands.. make sure its the full path.. if you read or write to files.. make sure you reference them via full path also.

share|improve this answer

My first guess would be paths of commands called within your script. When calling from cron, you don't get the environment settings your user does, so I would recommend every command being called in the script having a full path specified.

share|improve this answer

what distro, what cron server, show us the cron job config, check /var/log/cron, check /var/log/messages. most distros will try to email cron erros to the user who ran them, check /var/spool/mail/ (or actually setup working mail delivery).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.