{"id":4257,"date":"2025-10-07T06:15:34","date_gmt":"2025-10-07T06:15:34","guid":{"rendered":"https:\/\/code2deploy.com\/blog\/?p=4257"},"modified":"2025-10-07T06:15:35","modified_gmt":"2025-10-07T06:15:35","slug":"how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost","status":"publish","type":"post","link":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/","title":{"rendered":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>&nbsp;Introduction<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re running non-production environments such as <strong>staging, testing, or pre-production<\/strong> on AWS EC2, chances are your servers stay <strong>idle during off-hours<\/strong>.<br>Even when no one is using them, AWS continues charging for compute time \u2014 leading to unnecessary monthly costs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A smart and simple way to reduce your AWS bill is to <strong>automatically stop your EC2 instances during off-hours<\/strong> (e.g., at night) and <strong>start them again in the morning<\/strong>.<br>In this guide, we\u2019ll show how to do that using a <strong>cron job + AWS CLI<\/strong>, and we\u2019ll estimate how much you can save.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&nbsp;Why Auto-Stop EC2 Makes Sense<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many teams run development or pre-prod environments 24\/7 \u2014 even though they\u2019re used only 8\u201312 hours a day.<br>For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>QA servers used only in office hours<br><\/li>\n\n\n\n<li>Internal demo or staging environments<br><\/li>\n\n\n\n<li>Pre-prod servers used during testing cycles<br><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These idle hours silently <strong>consume compute cost<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By automating start\/stop, you can:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce monthly EC2 compute cost by <strong>30\u201350%<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Keep environments ready for use every morning<br><\/li>\n\n\n\n<li>Maintain all EBS data and configuration (since stopping doesn\u2019t delete volumes)<br><\/li>\n\n\n\n<li>Apply the method without any extra AWS service cost<br><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Real Example: Cost Comparison<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take an example of a <strong>t2.medium EC2 instance<\/strong> in Singapore (ap-southeast-1) region.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Plan<\/strong><\/td><td><strong>Runtime per Day<\/strong><\/td><td><strong>Monthly Hours<\/strong><\/td><td><strong>Approx. Monthly Cost<\/strong><\/td><\/tr><tr><td>Always On (24\u00d77)<\/td><td>24 hrs<\/td><td>720 hrs<\/td><td><strong>$33.41<\/strong><\/td><\/tr><tr><td>Scheduled (08:00\u201322:00)<\/td><td>14 hrs<\/td><td>420 hrs<\/td><td><strong>$19.49<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s a <strong>~42% cost reduction<\/strong> just by stopping the instance overnight.<br>If your previous month\u2019s bill was $51.81, you\u2019d bring it down to around <strong>$37.89<\/strong> \u2014 without changing instance type or performance.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&nbsp;Why Not Use Spot Instances Instead?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">AWS Spot Instances are a great way to cut costs (up to 90%), but they come with <strong>limitations<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Instances can be <strong>interrupted anytime<\/strong> when AWS needs capacity.<br><\/li>\n\n\n\n<li>Not ideal for long-running or stateful environments.<br><\/li>\n\n\n\n<li>You must design your system to handle <strong>instance termination<\/strong> gracefully.<br><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For <strong>pre-prod or test servers<\/strong> that need consistent uptime during work hours, <strong>auto start\/stop<\/strong> is a safer and more predictable alternative.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&nbsp;Implementation Using AWS CLI + Cron Job<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You don\u2019t need extra AWS services like Lambda or EventBridge (which add small costs).<br>You can run commands directly from your <strong>local server<\/strong> or <strong>management VM<\/strong> that already has AWS CLI configured.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Configure AWS CLI<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure you\u2019ve installed and configured AWS CLI with an IAM user that has permissions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>aws configure<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">IAM policy example (minimal):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>{<br>&nbsp; &#8220;Version&#8221;: &#8220;2012-10-17&#8221;,<br>&nbsp; &#8220;Statement&#8221;: [<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &#8220;Effect&#8221;: &#8220;Allow&#8221;,<br>&nbsp; &nbsp; &nbsp; &#8220;Action&#8221;: [<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;ec2:StartInstances&#8221;,<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;ec2:StopInstances&#8221;<br>&nbsp; &nbsp; &nbsp; ],<br>&nbsp; &nbsp; &nbsp; &#8220;Resource&#8221;: &#8220;EC2-ARN&#8221;<br>&nbsp; &nbsp; }<br>&nbsp; ]<br>}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Create Start\/Stop Scripts<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>start-ec2.sh<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>#!\/bin\/bash<br>aws ec2 start-instances &#8211;instance-ids i-0893e0c5ddd0ff2b5 &#8211;region ap-southeast-1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>stop-ec2.sh<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>#!\/bin\/bash<br>aws ec2 stop-instances &#8211;instance-ids i-0893e0c5ddd0ff2b5 &#8211;region ap-southeast-1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Make them executable:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>chmod +x start-ec2.sh stop-ec2.sh<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Or<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>#!\/bin\/bash<br># =====================================================<br># Simple EC2 Start\/Stop Script (for Preprod)<br># Instance: i-0893e0c5ddd0ff2b5<br># Region: ap-southeast-1<br># Author: Tom<br># =====================================================<br><br>INSTANCE_ID=&#8221;*****************&#8221;<br>REGION=&#8221;***********&#8221;<br>LOG_FILE=&#8221;\/var\/log\/ec2-scheduler.log&#8221;<br>ACTION=$1 &nbsp; # start or stop<br><br>timestamp() {<br>&nbsp; date &#8216;+%Y-%m-%d %H:%M:%S&#8217;<br>}<br><br>case &#8220;$ACTION&#8221; in<br>&nbsp; start)<br>&nbsp; &nbsp; aws ec2 start-instances &#8211;instance-ids &#8220;$INSTANCE_ID&#8221; &#8211;region &#8220;$REGION&#8221;<br>&nbsp; &nbsp; echo &#8220;$(timestamp) &#8211; Started EC2 $INSTANCE_ID&#8221; &gt;&gt; &#8220;$LOG_FILE&#8221;<br>&nbsp; &nbsp; ;;<br>&nbsp; stop)<br>&nbsp; &nbsp; aws ec2 stop-instances &#8211;instance-ids &#8220;$INSTANCE_ID&#8221; &#8211;region &#8220;$REGION&#8221;<br>&nbsp; &nbsp; echo &#8220;$(timestamp) &#8211; Stopped EC2 $INSTANCE_ID&#8221; &gt;&gt; &#8220;$LOG_FILE&#8221;<br>&nbsp; &nbsp; ;;<br>&nbsp; *)<br>&nbsp; &nbsp; echo &#8220;Usage: $0 {start|stop}&#8221;<br>&nbsp; &nbsp; ;;<br>esac<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Add Cron Jobs<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Edit your crontab:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>crontab -e<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Add these lines:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>0 8 * * * \/path\/to\/start-ec2.sh &gt;&gt; \/var\/log\/ec2_start.log 2&gt;&amp;1<br>0 22 * * * \/path\/to\/stop-ec2.sh &gt;&gt; \/var\/log\/ec2_stop.log 2&gt;&amp;1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;This will <strong>start the EC2 instance at 8 AM<\/strong> and <strong>stop it at 10 PM<\/strong> daily also you can add weekend scheduled<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&nbsp;Security &amp; Best Practices<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use a <strong>dedicated IAM user or role<\/strong> with minimal privileges.<br><\/li>\n\n\n\n<li>Rotate access keys regularly.<br><\/li>\n\n\n\n<li>Store AWS credentials securely in ~\/.aws\/credentials or via environment variables.<br><\/li>\n\n\n\n<li>Optionally add a <strong>Slack or email notification<\/strong> after each successful\/failed job.<br><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>&nbsp;Summary<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Feature<\/strong><\/td><td><strong>Auto Stop\/Start<\/strong><\/td><td><strong>Spot Instance<\/strong><\/td><\/tr><tr><td>Cost Savings<\/td><td>30\u201350%<\/td><td>Up to 90%<\/td><\/tr><tr><td>Reliability<\/td><td>High (Predictable uptime)<\/td><td>Low (Can be interrupted)<\/td><\/tr><tr><td>Best For<\/td><td>Pre-prod, staging, test<\/td><td>Batch jobs, CI\/CD, temporary workloads<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most companies keep their non-production servers running 24\u00d77, even when unused at night.<br>With a simple cron job and AWS CLI, you can <strong>cut your EC2 cost by up to 40%<\/strong> \u2014 safely, automatically, and without losing any data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;Introduction If you\u2019re running non-production environments such as staging, testing, or pre-production on AWS EC2, chances are your servers stay idle during off-hours.Even when no one is using them, AWS continues charging for compute time \u2014 leading to unnecessary monthly costs. A smart and simple way to reduce your AWS bill is to automatically stop [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87,33],"tags":[861,864,859,866,863,869,867,860,868,865,862],"class_list":["post-4257","post","type-post","status-publish","format-standard","hentry","category-aws","category-cloud-native-technology","tag-auto-stop-ec2","tag-aws-cli-automation","tag-aws-ec2-cost-optimization","tag-dev","tag-ec2-cron-job","tag-ec2-scheduling-without-lambda","tag-preprod-cost-optimization","tag-reduce-aws-bill","tag-save-money-on-aws","tag-stage","tag-start-stop-ec2-schedule"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com\" \/>\n<meta property=\"og:description\" content=\"&nbsp;Introduction If you\u2019re running non-production environments such as staging, testing, or pre-production on AWS EC2, chances are your servers stay idle during off-hours.Even when no one is using them, AWS continues charging for compute time \u2014 leading to unnecessary monthly costs. A smart and simple way to reduce your AWS bill is to automatically stop [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/\" \/>\n<meta property=\"og:site_name\" content=\"code2deploy.com\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-07T06:15:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-07T06:15:35+00:00\" \/>\n<meta name=\"author\" content=\"enam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"enam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/\"},\"author\":{\"name\":\"enam\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"headline\":\"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost\",\"datePublished\":\"2025-10-07T06:15:34+00:00\",\"dateModified\":\"2025-10-07T06:15:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/\"},\"wordCount\":771,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"keywords\":[\"auto stop EC2\",\"AWS CLI automation\",\"AWS EC2 cost optimization\",\"dev\",\"EC2 cron job\",\"EC2 scheduling without Lambda\",\"preprod cost optimization\",\"reduce AWS bill\",\"save money on AWS\",\"stage\",\"start stop EC2 schedule\"],\"articleSection\":[\"AWS\",\"Cloud computing\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/\",\"name\":\"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\"},\"datePublished\":\"2025-10-07T06:15:34+00:00\",\"dateModified\":\"2025-10-07T06:15:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\",\"name\":\"code2deploy.com\\\/blog\",\"description\":\"TechOps\",\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\",\"name\":\"enam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"caption\":\"enam\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/code2deploy.com\\\/blog\"],\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/author\\\/enam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/","og_locale":"en_US","og_type":"article","og_title":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com","og_description":"&nbsp;Introduction If you\u2019re running non-production environments such as staging, testing, or pre-production on AWS EC2, chances are your servers stay idle during off-hours.Even when no one is using them, AWS continues charging for compute time \u2014 leading to unnecessary monthly costs. A smart and simple way to reduce your AWS bill is to automatically stop [&hellip;]","og_url":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/","og_site_name":"code2deploy.com","article_published_time":"2025-10-07T06:15:34+00:00","article_modified_time":"2025-10-07T06:15:35+00:00","author":"enam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"enam","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/#article","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/"},"author":{"name":"enam","@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"headline":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost","datePublished":"2025-10-07T06:15:34+00:00","dateModified":"2025-10-07T06:15:35+00:00","mainEntityOfPage":{"@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/"},"wordCount":771,"commentCount":0,"publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"keywords":["auto stop EC2","AWS CLI automation","AWS EC2 cost optimization","dev","EC2 cron job","EC2 scheduling without Lambda","preprod cost optimization","reduce AWS bill","save money on AWS","stage","start stop EC2 schedule"],"articleSection":["AWS","Cloud computing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/","url":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/","name":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost - code2deploy.com","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/#website"},"datePublished":"2025-10-07T06:15:34+00:00","dateModified":"2025-10-07T06:15:35+00:00","breadcrumb":{"@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/code2deploy.com\/blog\/how-to-automatically-stop-and-start-your-aws-ec2-instance-to-save-cost\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code2deploy.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Automatically Stop and Start Your AWS EC2 Instance to Save Cost"}]},{"@type":"WebSite","@id":"https:\/\/code2deploy.com\/blog\/#website","url":"https:\/\/code2deploy.com\/blog\/","name":"code2deploy.com\/blog","description":"TechOps","publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code2deploy.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b","name":"enam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","caption":"enam"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g"},"sameAs":["https:\/\/code2deploy.com\/blog"],"url":"https:\/\/code2deploy.com\/blog\/author\/enam\/"}]}},"_links":{"self":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/comments?post=4257"}],"version-history":[{"count":1,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4257\/revisions"}],"predecessor-version":[{"id":4258,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4257\/revisions\/4258"}],"wp:attachment":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media?parent=4257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/categories?post=4257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/tags?post=4257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}