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

Cron jobs seem to be running as I see this in my /var/log/cron

Nov  5 09:00:01 glumbo CROND[18740]: (root) CMD (cd /var/www/domain.com/cgi-bin;./cron.pl >/root/cron.log 2>&1)

However, no output is saved to /root/cron.log

When I run the same command (cd /var/www/domain.com/cgi-bin;./cron.pl >/root/cron.log 2>&1) at the command line I get output saved to /root/cron.log

What is happening?

share|improve this question
    
cron has d different environment from your shell, have you double checked that you are setting PATH, and stuff in your script? –  Zoredache Nov 5 '11 at 7:45
    
Did you try running your script with the full path instead of doing a cd and the issuing ./cron.pl? –  Axel Knauf Nov 5 '11 at 15:51

2 Answers 2

up vote 3 down vote accepted

My first guess would be that when the job is run in cron, it's not being run as root somehow, and thus can't write to /root/cron.log. Check that and check the permissions on /root/cron.log.

Also, exactly what does 'cron.pl' do? Anything useful in /var/log/messages?

Try replacing the call to cron.pl with a simple 'echo' statement, then see if that is ending up in /root/cron.log.

share|improve this answer
    
It says root in the line I pasted in the question. cron.log is set to 666. Cron.pl checks a database to delete entries and then prints the number of entries deleted. Nothing in var/log/messages –  Matthew Hui Nov 5 '11 at 6:46

I've never liked stacking commands in cron -- it's almost always cleaner to have a wrapper script, and call that from cron.

I'm guessing that it's failing for some reason, and it's generating output which is being sent to mail, and either the mail's misconfigured and not being delivered, load's too high and mail delivery is suspended, root's mail is being forwarded elsewhere, or you haven't looked through root's mailbox.

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.