Disabling and enabling the cron

Hi All,

Please tell me what is command to disable and enable the cron in unix.

Thanks in Advance.

Regards,
Sindu

"cron" is not a service but a daemon. If it runs, it runs, if not, then not. Usually it runs. Usually it is started via some init-script, some systems (like AIX, for example, the System Resource Controller) have specialized mechanisms for starting certain daemons so it might not be about simply killing or invoking a process.

What exactly do you want to know or do?

Which system (version?) are you using?

I hope this helps.

bakunin

Hi Bakunin,

Thanks for replying.

Actucally I want to stop all the jobs in Crontab.

After some time have re-enable it.

Regards,
Sindu

try this
stop all jobs

# /etc/init.d/crond stop  >/dev/null 2>&1 && sed '/^#/!s/^/#/' /var/spool/cron/$USER >/usr/local/bin/${USER}.cr.tmp &&\
 cat /usr/local/bin/${USER}.cr.tmp > /var/spool/cron/$USER ;/etc/init.d/crond start

start all jobs

# /etc/init.d/crond stop >/dev/null 2>&1 && sed '/^#/s/^.//' /var/spool/cron/$USER >/usr/local/bin/${USER}.cr.tmp &&\
 cat /usr/local/bin/${USER}.cr.tmp > /var/spool/cron/$USER ;/etc/init.d/crond start
crontab -e

comment out each job that is listed in cron

brianjb is correct. Instead of stopping/starting the cron itself you can stop/start all the cron jobs.

It is possible to edit the crontab file via crontab -e , but there is an even easier way:

In most systems the crontab for each user resides in a file (for instance in AIX it is /var/adm/cron/crontab/<username> ). Move these files somewhere else to disable all cron jobs and move them back to reenable them.

CAUTION: the crontab command issues a refresh signal to crond after every change of a crontab file (this is why the file is not edited with a text editor). If you move the crontab files you will have to send a a signal 1 to crond to to make it aware of the changes.

kill -1 <PID-of-crond>

I hope this helps.

bakunin