Stopping and starting cron jobs

Deployment options: Netezza Performance Server for Cloud Pak for Data System

Learn how to stop and start cron jobs by using the crond service.

Stopping the crond service

  1. Inside the container, as the root user check whether status of the crond service is active (running).
    systemctl status crond
    Example:
    [root@e1n1-npshost nz]# systemctl status crond
    ● crond.service - Command Scheduler
       Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2021-08-23 05:30:42 EDT; 4s ago
     Main PID: 137685 (crond)
       CGroup: /system.slice/docker-6d0d8dd0927c762a7bf34490c1984a2de82a498ada2f45629da46235e29d3006.scope/system.slice/crond.service
               └─137685 /usr/sbin/crond -n -iAug 23 05:30:42 e1n1 systemd[1]: Started Command Scheduler.
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 40% if used.)
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) No inotify - daemon runs with -i or -c option ()
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
  2. Stop the crond service:
     systemctl stop crond
  3. Make sure that the status of the cornd service is inactive (dead):
    systemctl status crond
    Example:
    [root@e1n1-npshost ~]# systemctl status crond
    ● crond.service - Command Scheduler
       Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since Mon 2021-08-23 04:04:51 EDT; 7s ago
      Process: 461 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=0/SUCCESS)
     Main PID: 461 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/docker-6d0d8dd0927c762a7bf34490c1984a2de82a498ada2f45629da46235e29d3006.scope/system.slice/crond.service
               └─26699 /usr/sbin/anacron -sAug 23 04:00:01 e1n1 CROND[26182]: (nz) CMD (/nz/export/ae/utilities/bin/remote_controller.sh > /dev/null 2>&1)
    Aug 23 04:01:01 e1n1 crond[26689]: pam_systemd(crond:session): Failed to create session: Unit is masked.
    Aug 23 04:01:01 e1n1 CROND[26690]: (root) CMD (run-parts /etc/cron.hourly)
    Aug 23 04:01:01 e1n1 anacron[26699]: Anacron started on 2021-08-23
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.daily' in 15 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.weekly' in 35 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.monthly' in 55 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Jobs will be executed sequentially
    Aug 23 04:04:51 e1n1 systemd[1]: Stopping Command Scheduler...
    Aug 23 04:04:51 e1n1 systemd[1]: Stopped Command Scheduler.

Starting the crond service

  1. Inside the container, as the root user check whether status of the crond service is inactive (dead).
    systemctl status crond
    Example:
    [root@e1n1-npshost ~]# systemctl status crond
    ● crond.service - Command Scheduler
       Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since Mon 2021-08-23 04:04:51 EDT; 7s ago
      Process: 461 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=0/SUCCESS)
     Main PID: 461 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/docker-6d0d8dd0927c762a7bf34490c1984a2de82a498ada2f45629da46235e29d3006.scope/system.slice/crond.service
               └─26699 /usr/sbin/anacron -sAug 23 04:00:01 e1n1 CROND[26182]: (nz) CMD (/nz/export/ae/utilities/bin/remote_controller.sh > /dev/null 2>&1)
    Aug 23 04:01:01 e1n1 crond[26689]: pam_systemd(crond:session): Failed to create session: Unit is masked.
    Aug 23 04:01:01 e1n1 CROND[26690]: (root) CMD (run-parts /etc/cron.hourly)
    Aug 23 04:01:01 e1n1 anacron[26699]: Anacron started on 2021-08-23
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.daily' in 15 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.weekly' in 35 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Will run job `cron.monthly' in 55 min.
    Aug 23 04:01:01 e1n1 anacron[26699]: Jobs will be executed sequentially
    Aug 23 04:04:51 e1n1 systemd[1]: Stopping Command Scheduler...
    Aug 23 04:04:51 e1n1 systemd[1]: Stopped Command Scheduler.
  2. Start the crond service.
    systemctl start crond

    The status of the service is now active (running).

    Example:
    [root@e1n1-npshost nz]# systemctl status crond
    ● crond.service - Command Scheduler
       Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2021-08-23 05:30:42 EDT; 4s ago
     Main PID: 137685 (crond)
       CGroup: /system.slice/docker-6d0d8dd0927c762a7bf34490c1984a2de82a498ada2f45629da46235e29d3006.scope/system.slice/crond.service
               └─137685 /usr/sbin/crond -n -iAug 23 05:30:42 e1n1 systemd[1]: Started Command Scheduler.
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 40% if used.)
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) No inotify - daemon runs with -i or -c option ()
    Aug 23 05:30:42 e1n1 crond[137685]: (CRON) INFO (@reboot jobs will be run at computer's startup.)