1

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.

I'll-Be-Back
  • 693
  • 3
  • 9
  • 24

3 Answers3

2

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).

CloudWeavers
  • 2,511
  • 1
  • 14
  • 17
2

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
minniux
  • 398
  • 1
  • 6
2

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

ncowboy
  • 226
  • 2
  • 2