vendredi 28 août 2015

My EC2 instance starts itself five minutes after shutting down -- why?

My EC2 instance is set up, using a cron job, to shut itself down periodically. But five minutes after shutting itself down (which causes it to appear as "stopped" in AWS Console, as desired), it starts back up again! I have no idea why.

More detail:

I have a c4.xlarge that's got a cron job that runs every 15 minutes. The job checks if Java is running and if not, shuts itself down. Here's the line in the crontab:

*/15 * * * * pgrep java || /sbin/shutdown -h now

(Unnecessary detail: It is set up to be a Jenkins slave; Jenkins uses the AWS CLI to start the machine up when it needs to connect. After a job is run, Java isn't running, and we shut down the machine so that we're not paying full-time for a c4.xlarge.)

The cron job works. But then five minutes later, the instance comes back online. Looking in the syslog, I see this over and over:

Aug 28 14:30:01 tester1 CRON[2668]: (root) CMD (pgrep java || /sbin/shutdown -h now)
Aug 28 14:35:16 tester1 cron[1067]: (CRON) INFO (pidfile fd = 3)
Aug 28 14:35:16 tester1 cron[1125]: (CRON) STARTUP (fork ok)
Aug 28 14:35:16 tester1 cron[1125]: (CRON) INFO (Running @reboot jobs)

Any idea how I can keep it shut down once it's shut down? Why is it starting itself up?




Aucun commentaire:

Enregistrer un commentaire