# all the swap consumed while performing rsync?



## fluca1978 (May 21, 2010)

Hi all,
I've got a system running freebsd 8. The system has 2GB of RAM, a disk ad9 used as root and swap device and two disks (ad10, ad12) used as ZFS raid z pool. The swap is on ad9s4b and is large 8 GB.
The system works only as backup machine, executing a set of cron jobs that do rsync against other *nix machines.
While executing such jobs the machine become irresponsive and the top command shows:

```
Mem: 1306M Active, 162M Inact, 455M Wired, 47M Cache, 213M Buf, 3724K Free
Swap: 8000M Total, 7342M Used, 658M Free, 91% Inuse, 9488K In, 9856K Out
```

I don't understand if it is normal that such swap is so stressed, or if it is related to the ZFS or what.


----------



## SirDice (May 21, 2010)

Besides looking at the totals, also have a look at _which_ process is eating up all the memory. A 'simple' rsync should use that much memory.


----------



## fluca1978 (May 21, 2010)

Uhmm...having a look with top I found the following:


```
9530 backup      1  45    0  4396M   926M swread  1   7:43  0.00% bash
```

so such shell is consuming almost 1GB of resident memory (and is swapping). The problem is that I don't know from such information what the shell is doing, since it does not appear to me with the command line but only with the she-bang of the script running thru crontab.
Is there a smarter way to get the process and resources?


----------



## dennylin93 (May 21, 2010)

Switch to Bourne shell? Can't find a good reason to use Bash.


----------



## fgordon (May 21, 2010)

I recently rsynced ~ 10 TByte to my new FreeBSD backup machine - and I'm usig bash 
As my system HDs are SSD I log swap with rrdtool - but even afer 4 days of rsync running constantly swap was and still is "0"

This is no typical result of a bash / rsync combination - probably the script itself has an implementation error (maybe some recursion?)  switching shells will most probably not help anything... bash ist not really an untested or exotic software....


----------



## dennylin93 (May 21, 2010)

fgordon said:
			
		

> This is no typical result of a bash / rsync combination - probably the script itself has an implementation error (maybe some recursion?)  switching shells will most probably not help anything... bash ist not really an untested or exotic software....



This is the most likely reason. However, Bash is slower than Bourne shell though (shouldn't be noticeable most of the time).


----------



## phoenix (May 21, 2010)

fluca1978 said:
			
		

> Uhmm...having a look with top I found the following:
> 
> 
> ```
> ...



If that is a line from top, then press "a" to see the full command-line.  And play around with "C", "S", and other options (see "H" or "?" for more info).

You can also look at the output from `$ ps auwwx` to see what process called bash, and what processes were started by bash.


----------



## SirDice (May 21, 2010)

If you kill that process is the memory released?


----------



## fluca1978 (May 24, 2010)

This morning I found the system running out of swap space and not allowing any connection. Now I've deleted the bash script and I'm running rsync directly from crontab, monitoring the situation to see if it eats the swap.
However I didn't find any loop into the script to explain the extra-swap requests.


----------

