# Top process stopped



## keafao (Jul 11, 2016)

Hello,

I am newbie and moved a server to FreeBSD yesterday.

I was comparing my old Ubuntu server and new FreeBSD server. I notice that using top(1) the FreeBSD has less processes than Ubuntu and few that are stopped. Never saw stopped on Ubuntu.

41 processes:  1 running, 36 sleeping, 4 stopped

Should I worried? How to restart?


----------



## ASX (Jul 11, 2016)

keafao said:


> Should I worried?



Not only you will find stopped processes, you will find zombies too, you will be scared!


----------



## SirDice (Jul 12, 2016)

You shouldn't see any stopped processes. Can you post the output of `top -b`?



> How to restart?


The same way as on Linux: `shutdown -r now`


----------



## keafao (Jul 12, 2016)

Ok, thanks... here is top -b


```
last pid: 93362;  load averages:  0.43,  0.28,  0.25  up 3+23:35:17    08:08:12
45 processes:  1 running, 43 sleeping, 1 stopped

Mem: 1024M Active, 2475M Inact, 399M Wired, 22M Cache, 420M Buf, 41M Free
Swap: 

  PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME    WCPU COMMAND
93359 www           1  32    0   414M 90828K accept  0   0:03   9.08% php-fpm
93358 www           1  28    0   413M 91428K accept  0   0:02   7.37% php-fpm
93357 www           1  26    0   409M 89924K accept  1   0:02   7.28% php-fpm
73971 mysql        47  23    0  1883M  1112M uwait   0  33:26   6.98% mysqld
93227 www           1  20    0 86248K 13896K kqread  0   0:01   0.20% nginx
85846 root          1  20    0   383M 23096K kqread  1   0:06   0.00% php-fpm
  761 root          1  20    0 24160K  3612K select  0   0:03   0.00% sendmail
93226 www           1  20    0 86248K 14144K kqread  1   0:01   0.00% nginx
  778 root          1  20    0 16624K  1544K nanslp  1   0:01   0.00% cron
  487 root          1  20    0 14524K  1404K select  1   0:01   0.00% syslogd
  714 root          1  20    0 61316K  3952K select  0   0:00   0.00% sshd
  382 root          1  20    0 13632K  4392K select  1   0:00   0.00% devd
  247 root          1  43    0 14656K  1472K select  1   0:00   0.00% dhclient
92596 root          1  20    0 23600K  2960K pause   1   0:00   0.00% csh
72652 mysql         1  52    0 17096K  1688K wait    0   0:00   0.00% sh
  313 _dhcp         1  20    0 14656K  1520K select  0   0:00   0.00% dhclient
92591 ec2-user      1  20    0 86584K  5364K select  1   0:00   0.00% sshd
  764 smmsp         1  20    0 24160K  3300K pause   0   0:00   0.00% sendmail
```


----------



## SirDice (Jul 12, 2016)

I don't see anything stopped. I do see you haven't enabled any swap. I know the installer sometimes fails to add it correctly.


----------



## keafao (Jul 12, 2016)

It is a ec2 instance, probably I made something wrong.


----------



## SirDice (Jul 12, 2016)

Try and fix that first. The stopped processes may be because of it. Also, have a look at the output of `ps -aux`. See if there's anything out of place.


----------



## keafao (Jul 12, 2016)

What is your opinion about swap file? I was reading this

http://serverfault.com/questions/218750/why-dont-ec2-ubuntu-images-have-swap

Using ps-aux things I notice are:

[idle] with 200.0 %CPU
/usr/local/libexec/mysqld with 27.4 %MEM


----------



## SirDice (Jul 12, 2016)

keafao said:


> What is your opinion about swap file?


Have a look if they created a swap partition or not; `gpart show`.

If there's no swap partition you might want to create a swap file instead:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/adding-swap-space.html#create-swapfile

Ideally swap should be 2x the amount of physical memory but anything above 4GB is probably wasted space. Besides that, your instance may not have that much free disk space. As you have 1GB of memory I'd try to create a 2GB swap file if there's no swap partition. If you do have a swap partition enable it in /etc/fstab. 



> [idle] with 200.0 %CPU


This is normal if you have 2 cores (each 100%).


----------



## Murph (Jul 12, 2016)

keafao said:


> What is your opinion about swap file?



As an old-school UNIX admin, running a system with no swap configured just feels wrong.  On the other hand, running a system with swap where real money is charged per I/O seems utterly insane.  So, if there's a way to use the system's free-of-charge storage for a bit of swap, I'd certainly be doing that.

As a traditionalist, I much prefer swap partitions (or even swap drives) to swap files.  In the modern age, with SSD TRIM and the like, I can see where there's now a niche where a swap file is preferable.  As a bare minimum, 1x RAM is better than nothing for swap, but SirDice's recommendation of 2x is more reasonable.   If the free-of-charge disk space is there for it (and it wouldn't squeeze things too much for other stuff needing space), I'd go for at least 4x RAM or 16GB of swap.  Too much swap is generally better than too little.  If space is tighter than that, as much as will fit without causing pain, bearing in mind that it's not such a major issue to shrink a swap file later.

One of my reasons for going for a fairly generous swap allocation is that I'm a big fan of tmpfs(5), having worked with Solaris (where it is part of the default install) for decades.  To me, the swap partition/file is also the /tmp filesystem, for high speed scratch space.


----------



## keafao (Jul 12, 2016)

Thanks I will think more about what it is best to do...

Here is what I got when gpart show.


```
3  125829115  ada0  GPT  (60G)

          3         32     1  freebsd-boot  (16K)

        35  125829083     2  freebsd-ufs  (60G)
```




SirDice said:


> As you have 1GB of memory



My server has 4gb RAM



Murph said:


> On the other hand, running a system with swap where real money is charged per I/O seems utterly insane.



Yes maybe not for me today but I will try to check this on their calculator.


----------

