How do I disable cron jobs before startup?

Linode Staff

I need to clone my Linode, but without the cron jobs from the original Linode running once the cloned Linode has booted up. How might I go about that?

1 Reply

This is a great question! Thankfully, this can be accomplished pretty easily by utilizing Rescue Mode.


Step 1: Boot into Rescue Mode

By default, a cloned Linode will stay in a powered off state until its status is changed via the Cloud Manager -- this is a perfect opportunity to boot into Rescue Mode, a Finnix environment in which your Linode's disks - and the data therein - are accessible, but not mounted by default.

Step 2: Mount the disk that contains your Linode's crontab

For most, this will be /dev/sda -- which disk it actually is, though, doesn't matter too much here. All you'll need to mount the disk in question is run the following command:

mount -o exec,barrier=0 /dev/sda

Remember to swap out /dev/sda if you're mounting a different disk!

Step 3: Temporarily disable your Linode's cron jobs

Using sed, this can potentially be done with only one command. By inserting a hashtag ("#") before each line in your cron tabs, you'll prevent that cron job from running until the hashtag has been removed. To do so, you can use the following command:

sed -i 's/^/#/g' /example/file/here.txt

Step Four: Boot into your Linode normally

If all goes well, none of your Linode's cron jobs should run upon boot. Once you're ready to have your cron jobs resume, uncomment (remove the preceding hashtag) each cron job with another sed command:

sed -i 's/^#//g' /example/file/here.txt


And that's about it! If you do happen to run into any issues, or have any questions about this, feel free to let the rest of us know.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct