Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9034123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:24:24+00:00 2026-06-16T08:24:24+00:00

Is there a way to enable and disable Crontab tasks using Bash/Shell? So when

  • 0

Is there a way to enable and disable Crontab tasks using Bash/Shell?

So when the user starts Server 1, it will enable the Server 1 Crontab line and so on.
And when the user stops Server 1, the Server 1 Crontab line get disabled (#).
Is this possible and how?

Thanks in advance

*/1 * * * * Server 1 check
*/1 * * * * Server 2 check
*/1 * * * * Server 3 check
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:24:25+00:00Added an answer on June 16, 2026 at 8:24 am
    SERVERNUM=$1
    

    To enable:

    crontab -l | sed "/^#.*Server $SERVERNUM check/s/^#//" | crontab -
    

    To disable:

    crontab -l | sed "/^[^#].*Server $SERVERNUM check/s/^/#/" | crontab -
    

    Transcript:

    barmar@dev$ crontab -l
    */1 * * * * Server 1 check
    */1 * * * * Server 2 check
    */1 * * * * Server 3 check
    barmar@dev$ crontab -l | sed '/^[^#].*Server 1 check/s/^/#/' | crontab -
    barmar@dev$ crontab -l
    #*/1 * * * * Server 1 check
    */1 * * * * Server 2 check
    */1 * * * * Server 3 check
    barmar@dev$ crontab -l | sed '/^#.*Server 1 check/s/^#//' | crontab -
    barmar@dev$ crontab -l
    */1 * * * * Server 1 check
    */1 * * * * Server 2 check
    */1 * * * * Server 3 check
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to enable or disable a SQL SERVER trigger programmatically in
Is there any way to enable and disable a windows service using batch files.
Is there a way to disable/enable location services on iPhone simulator through objective c
I am display text in UIWebview as there any way to enable user to
Is there a way to disable/enable plugin per job or slave node? I'm looking
I want to enable or disable the button. Is there any way to drag
i wonder if there's a way to enable or disable servlets (or at least
Is there a way to enable/disable the View Whitespace feature in Visual Studion on
Is there a way to enable and disable all breakpoints in Eclipse...? I dont
Is there an easy way to enable or disable an IFrame to take it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.