Search code examples
linuxbashunixcronprocess-management

Linux, code that checks there are no currently running cron jobs?


How would I write a bash script that checks there are no currently running cron jobs, then does some simple action?

I am not talking about cron jobs that are scheduled to run at some point, I am referring to actively running processes.

Thanks!


Solution

  • intresting question ;)

    for pid in `pgrep cron`;do
      ps uh --ppid $pid;
    done|grep -v CRON