title: Linux CROND resource limits
body: <p>I have a machine with minified single user OS based on <strong>64bit Fedora 24</strong>:</p>
  
  <ul>
  <li>Vendor: Acer Veriton VN4640G</li>
  <li>CPU: Intel(R) Core(TM) i5-6400T CPU @ 2.20GHz</li>
  <li>RAM: 4GB DDR4 2133 MHz</li>
  <li>Storage: 32GB 2,5" ADATA SP600</li>
  </ul>
  
  <p>I wrote a simple script <code>/root/test.sh</code> which run 10000 processes on background:</p>
  
  <pre><code>ulimit -a &gt; /tmp/ulimit
  i=1
  while [ $i -le 10000 ]; do
      echo $i
      sleep 60 &amp; disown
      i=$(( $i + 1 ))
  done
  </code></pre>
  
  <p>When I run this script directly from console, it runs 10000 sleep processes and print numbers as expected.</p>
  
  <pre><code># bash test.sh
  1
  2
  ...
  9999
  10000
  
  # ps ax | grep -c [s]leep
  10000
  </code></pre>
  
  <p>Ulimit looks well</p>
  
  <pre><code># cat /tmp/ulimit
  core file size          (blocks, -c) unlimited
  data seg size           (kbytes, -d) unlimited
  scheduling priority             (-e) 0
  file size               (blocks, -f) unlimited
  pending signals                 (-i) 15339
  max locked memory       (kbytes, -l) 64
  max memory size         (kbytes, -m) unlimited
  open files                      (-n) 1024
  pipe size            (512 bytes, -p) 8
  POSIX message queues     (bytes, -q) 819200
  real-time priority              (-r) 0
  stack size              (kbytes, -s) 8192
  cpu time               (seconds, -t) unlimited
  max user processes              (-u) 15339
  virtual memory          (kbytes, -v) unlimited
  file locks                      (-x) unlimited
  </code></pre>
  
  <h1>BUT</h1>
  
  <p>if I run this script via cron (<code>/etc/cron.d/custom</code>), e.g.</p>
  
  <pre><code>0  8  *  *  *    root    bash /root/test.sh
  </code></pre>
  
  <p>I see in <code>journalctl -e -o cat</code> messages like:</p>
  
  <pre><code>(root) CMDOUT (494)
  (root) CMDOUT (495)
  (root) CMDOUT (496)
  (root) CMDOUT (/root/test.sh: fork: retry: Resource temporarily unavailable)
  (root) CMDOUT (/root/test.sh: fork: retry: Resource temporarily unavailable)
  (root) CMDOUT (/root/test.sh: fork: retry: Resource temporarily unavailable)
  (root) CMDOUT (/root/test.sh: fork: retry: Resource temporarily unavailable)
  (root) CMDOUT (/root/proc.sh: fork: Resource temporarily unavailable)
  </code></pre>
  
  <p>So it run only about 500 processes and then cann't fork any other process even if there is still enough resources and user limits are the same as console case.</p>
  
  <pre><code># free -h
                total        used        free      shared  buff/cache   available
  Mem:           3,8G        472M        2,8G         62M        498M        3,0G
  Swap:            0B          0B          0B
  </code></pre>
  
  <p>The count of running sleeps is always the same. <strong>Is there any recource limit for tasks run from cron?</strong></p>
  
  <p>P.S.: I did the test even on full Fedora 24 and result is the same...</p>