How do I disable cron jobs before startup?
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.
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.
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!
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
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.