Managing a Tweepy Twitter Bot on an EC2 instance can be challenging, especially when facing unexpected disk space issues. This article recounts my experience of rescuing my EC2 instance, which was running out of space due to Docker, and provides insights on effective resource management.
Photo by Christian Wiediger on Unsplash
The journey began with a perplexing error regarding disk space while trying to update my Tweepy Twitter Bot. A command revealed that the ‘/var’ directory, specifically Docker, was consuming most of the space. In a panic, I found a way to keep Docker under control by modifying /etc/docker/daemon.json
to limit log file sizes. But, the command failed due to no disk space!
After a tense moment, I recalled the ability to increase the size of my EC2 disk. Unfortunately, even after increasing the disk size and rebooting, Ubuntu was clueless about managing the extra space. Desperate for a solution, I turned to Google and stumbled upon the command journalctl --vacuum-time=3d
, which finally cleared enough space for me to resize my partition and breathe a sigh of relief.
With newfound space, I could finally run docker system prune -a
and clear up a significant amount of disk space. This experience highlighted the importance of proactive monitoring and led me to install Amazon CloudWatch Monitoring Scripts for Linux on my EC2 instance. These scripts, available here, provide valuable insights into instance performance and resource usage.
This article delves into the details of each step in the rescue process, offering practical advice and scripts for managing Docker and disk space on EC2 instances. It’s a must-read for anyone managing Tweepy Twitter Bots or similar applications on AWS, emphasizing the need for monitoring and efficient resource management.