0

I currently have 50 cron scripting jobs created on crontab -e. These scripts check that various services are running. Sometimes when I'm testing the functionality of one service this requires me to remove a lot of cron jobs. This makes the bells and whistles shooting off constant alerts off an outage. My workaround currently is to remove all of the cron manually by typing out nano crontab -e and running CTRL+K from the top of the list (not very fun to do). I want to know is it possible to disable cron quickly using a command rather than delete all the jobs and place them back in later on? Or can I create an empty text file and run a command to have cron read in that file and replace all the current jobs with that empty text file? Once I'm ready to use all my cron jobs again simply have it read in a text file that contains all my listed cron jobs.

1
  • For faster, more efficient editing, learn vim. It's not as hard or as scary as you might think. Start with vimtutor, you'll learn the basics in no time.
    – cas
    Commented Aug 22, 2019 at 4:35

2 Answers 2

8

Save your crontab to a file:

crontab -l > my-crontab

Delete your crontab:

crontab -r

Then load back the crontab from the file:

crontab my-crontab
1
  • thank you very much :)
    – The Chem X
    Commented Aug 22, 2019 at 13:40
1

If it's a single user system (maybe your desktop system, etc) the fastest and easiest way to suspend & restart all cron jobs is using systemd:

# to stop/suspend all cron jobs system-wide:
$ sudo systemctl stop cron.service

# to start/resume all cron jobs system-wide:
$ sudo systemctl start cron.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .