Stop cron job constantly rebooting ec2 instance

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I created a script to reboot system when CPU load hit 90%. But for some testing purpose I changed the value of max CPU Utilisation to 0.7%.



The script is programmed to run system reboot.



Now the server is never online - it constantly reboots.



My script:



#!/bin/bash
dstat| awk ' if (int($1)>0.7)
i=i+1;
print i, $1



if (int($1)>0.7)
j=j+1;

if (j>2)
print "system reboot";
cmd="sudo reboot";
system(cmd)

'


NB the script is programmed to run on reboot using crontab :



@reboot /bin/bash /ubuntu/home/reboot.sh


So I am unable to login using SSH. Because the system is constantly rebooting.



My server is an AWS ec2 instance



I have tried passing user data through aws console.



sudo apt-get purge dstat
cd /ubuntu/home && sudo rm reboot.sh
sudo /etc/init.d/cron stop


But it doesn't work.



So, any possible ways to get my instance back would be highly appreciated.







share|improve this question






















  • Can you set boot parameters? (I don't use AWS)
    – JanC
    May 1 at 19:16










  • Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
    – Anmol Rastogi
    May 2 at 5:54











  • You can put your own answer in and accept it then. :)
    – JanC
    May 2 at 17:10















up vote
0
down vote

favorite












I created a script to reboot system when CPU load hit 90%. But for some testing purpose I changed the value of max CPU Utilisation to 0.7%.



The script is programmed to run system reboot.



Now the server is never online - it constantly reboots.



My script:



#!/bin/bash
dstat| awk ' if (int($1)>0.7)
i=i+1;
print i, $1



if (int($1)>0.7)
j=j+1;

if (j>2)
print "system reboot";
cmd="sudo reboot";
system(cmd)

'


NB the script is programmed to run on reboot using crontab :



@reboot /bin/bash /ubuntu/home/reboot.sh


So I am unable to login using SSH. Because the system is constantly rebooting.



My server is an AWS ec2 instance



I have tried passing user data through aws console.



sudo apt-get purge dstat
cd /ubuntu/home && sudo rm reboot.sh
sudo /etc/init.d/cron stop


But it doesn't work.



So, any possible ways to get my instance back would be highly appreciated.







share|improve this question






















  • Can you set boot parameters? (I don't use AWS)
    – JanC
    May 1 at 19:16










  • Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
    – Anmol Rastogi
    May 2 at 5:54











  • You can put your own answer in and accept it then. :)
    – JanC
    May 2 at 17:10













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I created a script to reboot system when CPU load hit 90%. But for some testing purpose I changed the value of max CPU Utilisation to 0.7%.



The script is programmed to run system reboot.



Now the server is never online - it constantly reboots.



My script:



#!/bin/bash
dstat| awk ' if (int($1)>0.7)
i=i+1;
print i, $1



if (int($1)>0.7)
j=j+1;

if (j>2)
print "system reboot";
cmd="sudo reboot";
system(cmd)

'


NB the script is programmed to run on reboot using crontab :



@reboot /bin/bash /ubuntu/home/reboot.sh


So I am unable to login using SSH. Because the system is constantly rebooting.



My server is an AWS ec2 instance



I have tried passing user data through aws console.



sudo apt-get purge dstat
cd /ubuntu/home && sudo rm reboot.sh
sudo /etc/init.d/cron stop


But it doesn't work.



So, any possible ways to get my instance back would be highly appreciated.







share|improve this question














I created a script to reboot system when CPU load hit 90%. But for some testing purpose I changed the value of max CPU Utilisation to 0.7%.



The script is programmed to run system reboot.



Now the server is never online - it constantly reboots.



My script:



#!/bin/bash
dstat| awk ' if (int($1)>0.7)
i=i+1;
print i, $1



if (int($1)>0.7)
j=j+1;

if (j>2)
print "system reboot";
cmd="sudo reboot";
system(cmd)

'


NB the script is programmed to run on reboot using crontab :



@reboot /bin/bash /ubuntu/home/reboot.sh


So I am unable to login using SSH. Because the system is constantly rebooting.



My server is an AWS ec2 instance



I have tried passing user data through aws console.



sudo apt-get purge dstat
cd /ubuntu/home && sudo rm reboot.sh
sudo /etc/init.d/cron stop


But it doesn't work.



So, any possible ways to get my instance back would be highly appreciated.









share|improve this question













share|improve this question




share|improve this question








edited May 1 at 19:05









Zanna

48k13119227




48k13119227










asked Apr 26 at 14:13









Anmol Rastogi

92




92











  • Can you set boot parameters? (I don't use AWS)
    – JanC
    May 1 at 19:16










  • Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
    – Anmol Rastogi
    May 2 at 5:54











  • You can put your own answer in and accept it then. :)
    – JanC
    May 2 at 17:10

















  • Can you set boot parameters? (I don't use AWS)
    – JanC
    May 1 at 19:16










  • Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
    – Anmol Rastogi
    May 2 at 5:54











  • You can put your own answer in and accept it then. :)
    – JanC
    May 2 at 17:10
















Can you set boot parameters? (I don't use AWS)
– JanC
May 1 at 19:16




Can you set boot parameters? (I don't use AWS)
– JanC
May 1 at 19:16












Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
– Anmol Rastogi
May 2 at 5:54





Idk how to set boot parameters. Thanks for suggesting though. :) Actually i found the solution. I detached my root volume from the instance and attached/mounted it on my other instance and then i opened up the mounted volume and remove the script and then detached it and attached it as root volume to the original instance. This worked as the script required was no longer there. So the system booted up perfectly. :)
– Anmol Rastogi
May 2 at 5:54













You can put your own answer in and accept it then. :)
– JanC
May 2 at 17:10





You can put your own answer in and accept it then. :)
– JanC
May 2 at 17:10
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028424%2fstop-cron-job-constantly-rebooting-ec2-instance%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028424%2fstop-cron-job-constantly-rebooting-ec2-instance%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491