How to Comment out a line in a Crontab on Linux

Firstly let’s just note that crontabs are read in the following way:

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

Your current crontabs can be viewed on your linux setup by typing in the following command:

crontab -e

Now to get to the point of this article, how would you temporarily disable a line/command without deleting the line? It’s quite simple actually, all you have to do is comment out that line / multiple lines by adding a hash in front of the line as follows:

Before:

00 12 * * * php /var/www/example.com/crons/somecron.php

After:

# 00 12 * * * php /var/www/example.com/crons/somecron.php

Note the trailing # hash symbol which is how you comment out a line in a crontab.

Wasn’t that easy?

Tags:

Leave a Reply

Your email address will not be published.