# Matter with cron



## rrojas (Jul 19, 2010)

Hello 

I run on Freenas 7.2.
I want to run a script in cron.
But a part of my script return false computing when it turn on cronjob.
You can see the problem line on my crontab file.

Next my crontab file:


```
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hour    mday    month   wday    who     command
#
# Perform email status report.

54 12 * * * root find /mnt/data/home -mtime 1 -type f -exec ls -as {} \; | grep "dom_" | awk '{ SUM += $1} END { print SUM/1024/1024 }' >> /root/log/tata.txt
```

when I execute the line directly in commande line, It display a good result and 
When I execute the line whith cron, it display a false result (It multiply by two the Good result)

Perhaps anyone have meet this problem

Thanks RAF


----------



## aragon (Jul 19, 2010)

Maybe a shell quoting issue.  You really should be putting that into a shell script and calling the script from cron instead.


----------



## rrojas (Jul 19, 2010)

Thanks aragon,

I try too with a shell script, but I have the same problem.

I continue to search for.

RAF


----------



## gordon@ (Jul 19, 2010)

Your block size is not set. From the ls(1) manpage:


```
-s      Display the number of [b]blocks[/b] used in the file system by each
             file....
```

Then further below:

```
[b]The default block size is 512 bytes.[/b]  The block size may be set with
     option -k or environment variable BLOCKSIZE.  Numbers of blocks in the
     output will have been rounded up so the numbers of bytes is at least as
     many as used by the corresponding file system blocks (which might have a
     different size).
```

Information for using -k:

```
-k      This has the same effect as setting environment variable
             BLOCKSIZE to 1024, except that it also nullifies any -h options
             to its left.
```

If you look in your interactive shell, you will see that your BLOCKSIZE environment variable is set to 'K.' Your easiest solution is to add -k to your ls(1) invocation:

```
54 12 * * * root find /mnt/data/home -mtime 1 -type f -exec ls -ask {} \; | grep "dom_" | awk '{ SUM += $1} END { print SUM/1024/1024 }' >> /root/log/tata.txt
```


----------



## rrojas (Jul 20, 2010)

Thanks Gordon@

That works.

Thanks at all

Raf


----------

