# generating sarg reports, and rotating squid logs.



## crazychip (Oct 13, 2011)

Hi,

I am trying to set up a log rotation/report generating scheme for squid and sarg. Since I'm not real steady on the basics of logging and cron I was wondering if my plan will work or if anyone has a better idea on how I could do this.

1) newsyslog rotates the squid access.log on midnight to an uncompressed .0: 

```
/var/log/squid/access.log      644  1     *    @T00  B     /var/log/squid/squid.pid  30
```

2) cron then runs sarg that generates report from the access.log.0 file 5 min later.

```
5 * * * * root sarg
```

3) newsyslog then archive the access.log.0 file an 5 min later.

```
/var/log/squid/acess.log.0              600  6     *    @T0010 BZ
```

Is this a good plan or am I oblivious to reason this won't work?


----------



## mix_room (Oct 13, 2011)

If my "cron-skillz" don't fail me, then your sarg-job will be run every five minutes. You need to tell it to run at a given hour aswell.


----------



## crazychip (Oct 13, 2011)

HÃ¸yre cron-skillz are still good  but isn't it running 5 min past every hour?


----------



## crazychip (Oct 13, 2011)

*your


----------



## jem (Oct 13, 2011)

squid has it's own log rotation function.

`# squid -k rotate`

You could just pop that into crontab at a suitable time.


----------



## crazychip (Oct 14, 2011)

squids rotate function was real easy to use so i went with that.

now i rotate the squid logs at the start of every week and generate the sarg report 5 min later. i also rotate 10 time, giving me 10 weeks of logs. sarg makes reports based on access.log.0


```
# Rotate squid logs every monday at midnight
0      0       *       *       1       root squid -k rotate
# Generate a sarg report for the week 5 min after the files rotates
5      0       *       *       1       root    sarg
```


----------



## shitson (Oct 14, 2011)

```
5 * * * * root sarg
```

Will run every 1hr at 5 minutes past (i.e For every value of hr when minute is 5, run)


```
*/5 * * * * root sarg
```

Will run every 5 minutes (i.e For every 5th value of minute, run)


----------



## crazychip (Oct 18, 2011)

*problem*

On Monday I got a not so happy mail from Cron Deamon that said my cron jobs failed.


```
squid: Permission denied
sarg: not found
```
/etc/crontab:

```
# Rotate squid logs every monday at midnight
0       0       *       *       1       root    squid -k rotate

# Generate a sarg report for the day 5 min after the file rotates
5       0       *       *       1       root    sarg
```

is the crontab wrong?
where do i start looking?


----------



## wblock@ (Oct 18, 2011)

crazychip said:
			
		

> is the crontab wrong?



Yes.



> where do i start looking?



Here, #2.


----------



## crazychip (Oct 18, 2011)

nice answer wblock@ 
is there a way to test the crontab without waiting till next monday or changing the time?


----------



## wblock@ (Oct 18, 2011)

Copy the entry, but change the time to be two minutes from now.  Or you could simulate it by starting a new sh, setting the path as it is one line 6 of /etc/crontab, and running the command from there.  The first is a more realistic test.


----------

