2

We have a very sensitive application which heavily makes use of crontab and we would like to track of how many processes started by crontab are still running.

In short, we have a limit of 300 cron jobs in 'queuedefs' and we want to make sure that we are not reaching it.

Sincerely, Dumb Admin

Dumb admin
  • 127
  • 12

2 Answers2

3

This will get you a list of processes whose parent is crond:

ps h --ppid $(pgrep crond)
Ian
  • 376
  • 1
  • 6
  • I ended using this solution. The script checks every execution the crond ID and uses to list its children. Thanks! – Dumb admin Oct 07 '15 at 13:31
2

Looks like the PID of crond varies on each invocation. So, how about this?

for pid in  $(ps -ef | grep -i crond | awk '{print $2}') ; do
  ps -ef | grep -vi crond | awk -v ppid=${pid} '{if ($3 == ppid) print $0}'
done | wc -l

This'll print out a count of all processes that have been started by a process called crond.

drew
  • 173
  • 1
  • 6