o comment out a cron job within crontab -e, effectively disabling it without deleting the entry, the following steps are required: Open the crontab for editing.
crontab -e
This command opens your user’s crontab file in the default text editor.
- Locate the cron job: Navigate to the line containing the cron job you wish to comment out.
- Add a hash symbol: Insert a hash symbol (
#) at the very beginning of the line containing the cron job.
For example, to comment out the following cron job:
0 0 * * * /usr/bin/my_script.sh
Change it to:
# 0 0 * * * /usr/bin/my_script.sh
- Save and exit: Save the changes in your text editor and exit. The method for saving and exiting depends on the editor being used (e.g., in Vim, type
:wqand press Enter).
After saving, the cron daemon will recognize the line as a comment and will no longer execute the associated command. To re-enable the cron job, simply remove the leading hash symbol from the line using the same crontab -e process.
