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 don't understand why cron is not really executing the command every 10 minutes.

in crontab -e I have added:

*/10 * * * * /var/www/myproject/recording/batch.pl

I could see in the cron log it is running every 10 mins:

Mar 17 10:50:01 host crond[26335]: (root) CMD (/var/www/myproject/recording/batch.pl)
Mar 17 11:00:01 host crond[26357]: (root) CMD (/var/www/myproject/recording/batch.pl)
Mar 17 11:10:01 host crond[26418]: (root) CMD (/var/www/myproject/recording/batch.pl)
Mar 17 11:20:01 host crond[26657]: (root) CMD (/var/www/myproject/recording/batch.pl)

but it is not really executing the command.

When I execute that command manually in the Linux console it is working fine.

share|improve this question
    
Did you check your email? –  Michael Hampton Mar 17 '13 at 11:31
    
@MichaelHampton No? Where do I check that on Linux –  I'll-Be-Back Mar 17 '13 at 11:33
    
try putting /path/to/perl in front of your command –  Tim Haegele Mar 17 '13 at 11:35

3 Answers 3

up vote 2 down vote accepted

how about setup your crontab like this

*/10 * * * * /usr/bin/perl /var/www/myproject/recording/batch.pl 2>&1 | tee -a /var/log/myproject-recording-batch.log

then you can tail the log file /var/log/myproject-recording-batch.log to trace the running

share|improve this answer
    
Thank you! Log explained what was the problem was. –  I'll-Be-Back Mar 18 '13 at 21:24

CRON doesn't inherit all your environments variables. Some software must be manually called (ie: calling ifconfigor /sbin/ifconfig is not equal if you don't have a valid $PATH environment variable).

Also make sure it is executable and that your shebang is correctly defined (otherwise you'll have to prepend your command with the interpreter).

share|improve this answer

As CloudWeavers said, it most be about a missing environmental variable, to check what exactly is missing you can edit the cronjob to log all it's standard output/error to a log file, so that you can review it to get what's stopping it:

*/10 * * * * /var/www/myproject/recording/batch.pl &> output.log
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.