How to Comment out a line in a Crontab on Linux

0 min read 174 words

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:
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags

Recent Posts