I know the standard way to disable a task in cron is to comment the line with the task using the # sign in front of it, as with most Unix config files or shell scripts. e.g.:

53 23 * * * /home/dolan/y-u-du-dis.sh 2>&1 

That's fine for just one task, but it's really annoying having to comment 100 lines or so... so the question is: Is there a way to comment more than one entry at a time in cron? Something like multi-line comments, or a shortcut to comment everything in the crontab...

I found this question and answer in ServerFault, which basically says that you can't.

1 Answer 1


The answer from SF is accurate as far as it goes, though if all the lines you wish to comment are in one block there is a way "around" this problem. It's not standard practice, and the end result is individual comment markers on every line. My editor of choice for crontab files is vi, so other editors may or may not have similar functionality, but if you wish to comments lines 5 through 80, you could issue the following command sequence in vi:

 :5,80s/^/# /

Which has the effect of putting a '# ' at the beginning of lines 5 through 80. Hackish? Absolutely. Effective? Under the constraints I've given, yes.

  • Right now, I'm using AIX with vi as the default text editor, so this works like a charm. Thanks!
    – jimm-cl
    Jun 26, 2015 at 13:00
  • Love this answer - major time saver, thank you! If anyone is wondering, to edit the crontab with vi try this: export VISUAL=vim; crontab -e
    – ttemple
    Jul 17, 2018 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.