Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple bash script wich works fine when running in command line, but not in crontab:


for f in /data/home/cwolff/tmp/*access_log*.txt;
egrep "r:[A-Z]+ \S+[^\.\s]{5} " $f >> $f.min

When running in crontab it outputs empty *.min files. I read about some character like % need to be escaped in crontab, but I'm not using any of them.

share|improve this question
my crontrab entry looks like this: '22 9 * * * /data/home/cwolff/scripts/' – rontron Feb 3 '12 at 8:55
up vote 3 down vote accepted

Be careful with ranges like [A-Z], as the meaning of that depends on the locale. It might be [ABC...], but it might also be [AaBbCc...]. [:upper:] is well-defined.

So, my best bet would be to check the environment in your login shell vs cron, especially LC_ALL, LC_COLLATE, LC_CTYPE, LANG.

share|improve this answer
thanks a lot - setting the LANG env in crontab solved this issue! – rontron Feb 3 '12 at 12:05

This could be caused by permissions.

You would see exactly this behaviour if you have permission to read all the files in /data/home/cwolff/tmp/*access_log*.txt but the user whose crontab you are running this from doesn't.

This will also be the case if /data is mounted using NFS without the no_root_squash option and the crontab is root's.

Errors from cron jobs are usually mailed to the user in question. If you haven't spent any time configuring your mail setup, these are probably in /var/spool/mail/user.

share|improve this answer

Your Answer


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.