Disabling and enabling the cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Disabling and enabling the cron
# 1  
Old 05-18-2012
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
# 2  
Old 05-18-2012
"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
# 3  
Old 05-18-2012
Hi Bakunin,

Thanks for replying.

Actucally I want to stop all the jobs in Crontab.

After some time have re-enable it.

Regards,
Sindu
# 4  
Old 05-18-2012
try this
stop all jobs
Code:
# /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
Code:
# /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

# 5  
Old 05-18-2012
Code:
crontab -e

comment out each job that is listed in cron
# 6  
Old 05-18-2012
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.

Code:
kill -1 <PID-of-crond>

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Hardware

How disabling GPU?

Hi All I'm find out a way to disable the DGD: AMD Radeon HD 7470M on my Ubutu 16.04.2 LTS because radeon open source module is not capable to support this GPU and consequence the boot is very slow. I have tried serveral way with pci-stub.ids in the grub menu but not work. In general how... (11 Replies)
Discussion started by: _Fabio_79
11 Replies

2. AIX

Disabling cron after NIM restore

Hi Guys, We normally have a backup and restore nightly on our Prod machines. We do this via customized script and all unattended. The dilemma that I'm having is the disabling of the cron after the restore. I created a nim script to disable the cron after the restore has been completed. But... (6 Replies)
Discussion started by: kaelu26
6 Replies

3. UNIX for Dummies Questions & Answers

How to Disabling cron for few hours each day

Hi Is there any way to disable cron adhoc ? I want to run a script for every one minute between 04 to 00 hours will the below serves my purpose ? 01 04-00 * * * <your script> (1 Reply)
Discussion started by: rakeshkumar
1 Replies

4. Solaris

Disabling sendmail

Hello everyone, can anyone tell me how to disable sendmail on solaris 10? I seem to have the sendmail process from hell. Did an SVCS | grep for mail and disabled the 2 processes it threw up. But something is still respawning sendmail (if I kill it manually) and it's doing the usual... (2 Replies)
Discussion started by: callmebob
2 Replies

5. Shell Programming and Scripting

disabling and enabling the crontab

Hi All, I need disable all the crontab job in the cron and then later have to enable the crontab job by shell scripting. or otherwise disable the cron and enable cron again by means of unix shell scripting. Please can you one help me out in this. Thanks in Advance. Regards, Sindu (2 Replies)
Discussion started by: indira_s
2 Replies

6. Shell Programming and Scripting

enabling/disabling an oracle trigger

hi, i want to disable and then enable an oracle trigger through shell script. Please tell me how it can be done? (1 Reply)
Discussion started by: ss_ss
1 Replies

7. UNIX for Dummies Questions & Answers

disabling telnet

how do i disable the telnet (2 Replies)
Discussion started by: rmuhammad
2 Replies

8. UNIX for Dummies Questions & Answers

Ports Disabling

I will want to disable all the ports not needed in my UNIX. If I put a # sign at the beginning of the line of the port name I want to disable in /etc/services.... that's all????? Or I need to do anything else to disable a port???? (1 Reply)
Discussion started by: rrivas
1 Replies
Login or Register to Ask a Question