How do you freeze a cron job for maintenance and re-enable after the maintenance window?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

How do you freeze a cron job for maintenance and re-enable after the maintenance window?

Explanation:
When you want to pause a specific cron job for a maintenance window, the simplest and safest approach is to disable just that line in your crontab by turning it into a comment. Open the crontab with crontab -e, put a hash symbol (#) at the start of the line for the job you want to pause, and save. Cron will ignore that line because it’s a comment, effectively freezing the job. After maintenance, edit the crontab again and remove the # to re-enable it, then save. This keeps the rest of your scheduled tasks intact and avoids touching system-wide cron settings. Stopping the cron daemon would halt all scheduled tasks, which is not desirable for a single job. Removing a file from /etc/cron.d affects all jobs defined there and is too heavy-handed for a temporary pause. Using crontab -r would remove the entire crontab, requiring you to recreate it later, which is error-prone for a temporary maintenance period.

When you want to pause a specific cron job for a maintenance window, the simplest and safest approach is to disable just that line in your crontab by turning it into a comment. Open the crontab with crontab -e, put a hash symbol (#) at the start of the line for the job you want to pause, and save. Cron will ignore that line because it’s a comment, effectively freezing the job. After maintenance, edit the crontab again and remove the # to re-enable it, then save.

This keeps the rest of your scheduled tasks intact and avoids touching system-wide cron settings. Stopping the cron daemon would halt all scheduled tasks, which is not desirable for a single job. Removing a file from /etc/cron.d affects all jobs defined there and is too heavy-handed for a temporary pause. Using crontab -r would remove the entire crontab, requiring you to recreate it later, which is error-prone for a temporary maintenance period.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy