Cron – Does not execute command every 10 mins

Posted on

Cron – Does not execute command every 10 mins – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, centos, cron, incrontab, .

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/

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/
Mar 17 11:00:01 host crond[26357]: (root) CMD (/var/www/myproject/recording/
Mar 17 11:10:01 host crond[26418]: (root) CMD (/var/www/myproject/recording/
Mar 17 11:20:01 host crond[26657]: (root) CMD (/var/www/myproject/recording/

but it is not really executing the command.

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

Solution :

how about setup your crontab like this

*/10 * * * * /usr/bin/perl /var/www/myproject/recording/ 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

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

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/ &> output.log

Leave a Reply

Your email address will not be published.