Home > 14.04 > Command to ON/OFF cron job

Command to ON/OFF cron job

October 11Hits:2

Is there any command that can switch ON/OFF cron job in Ubuntu?

As far I know to open crontab -e and comment out each cron job. Is there any single command to stop all cron job and restart later?

Currently I have multiple cron jobs running on different time to send email alerts, monitoring results, automatic DB update(hourly), weekly status etc

But then during maintenance time, I need to stop all these cron jobs and restart once maintenance is over. Now disabling one by one with # symbol.

Is there any solution?


For the single cron job you can comment by editing crontab -e If you have to stop all the cronjobs:

 sudo service crond stop

 sudo service crond status

 sudo service crond restart


 /etc/init.d/cron start

 /etc/init.d/cron status

/etc/init.d/cron restart

Related Articles

  • ssh fails to execute remote command when run from cron bash script - works from CLIJanuary 19

    I have a script, written in bash, which runs from cron. One of the first things it does is SSH to a remote host and retrieve a list of files in a directory. Everything works fine when run from the command line, but not from cron. The section of the s

  • Command to ON/OFF cron jobOctober 11

    Is there any command that can switch ON/OFF cron job in Ubuntu? As far I know to open crontab -e and comment out each cron job. Is there any single command to stop all cron job and restart later? Currently I have multiple cron jobs running on differe

  • Run a command every week with Cron?November 7

    Simple question- what would a crontab entry look like for a command I want to run every week on Saturday at 8:05 AM? --------------Solutions------------- That should do it: 5 8 * * 6 <user> <command> or for readability 5 8 * * Sat <user>

  • The 'which' command returns nothing via cron, but works via consoleApril 26

    I've written a little utility in haXe + Neko that needs to execute some GIT commands. To avoid hardcoding the path to the GIT executable I'd like to use the which command to find out where it is. Everything works as expected when running manually fro

  • s3cmd run on command line not on cronDecember 3

    Many have said that the problem is with environment but I still can't seem to solve this problem. BTW I am using Ubuntu 9.10 login as user, then sudo -s using this command: s3cmd put file s3://bucket >>worked! now here is the simple script intended

  • Will this code (command) work in a cron job, or do I need to put it into a file?February 1

    Some commands I use (i.e rsync) work fine in cron jobs; Will this: find /path/to/files* -mtime +30 -exec rm {} \; ...or do I need to put it into a file? I can test it myself soon, however asking may save precious time. --------------Solutions--------

  • Give www-data Permission To Reload Nginx Works Via Command Line but not cron November 17

    This is a Canonical Question about using cron & crontab. The answer for 'Why is my crontab not working, and how can I troubleshoot it?' can be seen below. This addresses the cron system with the crontab highlighted. --------------Solutions-----------

  • sudo command not working in cronMay 23

    I have a small script and I want to run it as user1 in cron. If I am logged in as user1 and execute the script it works just fine, but the moment I try to run it in cron it does not work. If I run the cron as root everything works. Here is what I am

  • command not running in cron (systemctl suspend)September 15

    I have this cronjob set : * * * * * /usr/bin/systemctl suspend And it is not working. But I can run it in a shell and it works. I don't understand what could be not working. EDIT Redirecting error output to /tmp/error gives this : Failed to issue met

  • mailx command strange behaviour from cronSeptember 19

    I have a script that redirect the df output to a file and then send it in an email. The mail command is set up as following: /usr/bin/mail -s "Subject" -r [email protected] [email protected] < /tmp/diskSpace.txt Everything is working cor

  • XRandR script runs correctly from command line, fails as cron jobJuly 10

    I'm running LXDE on Fedora 21. My script's purpose is to extend the display across two monitors: #!/bin/sh xrandr --output VIRTUAL1 --off --output LVDS1 --mode 1440x900 --pos 1280x124 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024

  • @reboot works with command but not script - CronOctober 24

    So I am trying to run a script as a specific user @boot. I have come across using @reboot in conjunction with crontab. I have found that @reboot is supported by both the user and root via @reboot echo "hello" > /root/hello.sh and same for a r

  • What happens if shutdown command kills my unison cron job?November 15

    I have an Arch linux box at home that I power off quite frequently (the power supply is noisy and it annoys my girlfriend...!). The box has a number of cron jobs running the unison utility, designed to back up various directories onto external hard d

  • How can I execute sudo commands as a cron job?October 10

    I'm trying to execute a shell script as a cron job. The problem is that my script needs to be run as a super user. I tried it with just writing sudo infront of the command in my crontab file, but it didn't work. --------------Solutions------------- C

  • Cron job with $(date) command and redirect won't runDecember 19

    This is the cron job I'm trying to run nightly: 0 20 * * * /data/code/scripts/foo.sh >/root/foo.$(date +%Y-%m-%d-%T).log 2>&1 When I run it from the command line, it works fine. But Cron doesn't appear to even try and run it. Thoughts? ---------

  • How can I run a cron command with existing environmental variables?December 21

    How can I run a cron command with existing environmental variables? If I am at a shell prompt I can type echo $ORACLE_HOME and get a path. This is one of my environmental variables that gets set in my ~/.profile. However, it seems that ~/.profile doe

  • Custom directory for cron commandsMay 27

    I'm using vixie cron on Debian/Ubuntu. How to set a custom directory to be read by cron? I want to lead crontab to run commands found in a series of files, e.g. /home/cron/*.cron or perfectly /home/*/cron/*.* In fact, instead of putting cron commands

  • Why can't cron job find basic Linux commands?February 20

    I'm trying to set up a cron job to run a PHP script daily as part of a web-based booking system. It's been running perfectly for several years on a different Apache server using this in the crontab: 0 3 * * * wget -q -O /dev/null http://www.my_other_

  • Giving cron permission to execute commandJanuary 12

    I'm trying to get a ruby script to run via cron. The cron job looks like this: * * * * * /usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby /usr/share/adafruit/webide/repositories/shed_watcher/lib/shed_watcher.rb >> /tmp/cron_shed_watcher.log 2>&

  • How to remove or delete single cron job using linux command?January 21

    I have created cron jobs for my site which is listed below and they are working fine. I print all cron job by using this PHP script: $cronfiles=exec('crontab -l',$output); echo "<pre>"; print_r($output); Which outputs: [0] => 0 0 * * *

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.439 s.