Nice and Simple AWS EC2 Start Stop Script – Python

Here is a nice and simple AWS EC2 start stop script written in Python and run from the command line. The parameters are just start|stop and the name of your instance.

I’ve written it so it uses the tag Name instead of requiring the specific instance ID. The script’s ideal usage may be to schedule the start|stop of an instance at particular times of the day. So you might have a test server you use during 10AM and 3PM Monday to Friday. With this script you could setup a scheduled task on a remote computer to start|stop the instance based on your schedule, saving you money!


In order to run this script you’ll need to have Python and the AWS library Boto installed on your computer. Remember this can be any computer with an internet connection (ideally not the EC2 instance you plan on stopping/starting). The script will run on Linux and Windows.

I’ve previously written guides on installing Python and Boto into Linux environments. If you use Windows, you will find many guides stepping you through this process.
Continue reading…

Python MySQL Backup Script

Here is a simple python based MySQL backup script. It will individually dump all your MySQL databases and then tar gzip them to a specified location.

Having Python installed is the only real prerequisite.

Script Details

Note, that the script isn’t verbose unless there is an error. This is so you can schedule it as a cron job, and only get an email when something goes wrong.

It also uses a configuration file as a security precaution. The reason for using a config file, it prevents the user and password being visible in the running processes list. So for example if you were running a mysqldump and put password into your command line, another user could query the running processes and see the password.

I typically store my scripts in the /usr/local/bin directory of my Linux systems. In general, it’s a good place to store custom scripts and applications.

You’ll also need to create your configuration file, like below:

In my case, I store the config file as /etc/mysql.cnf however make sure that it’s only readable by the root user.

Continue reading…

Adempiere Startup Script for CentOS

This is a simple Adempiere startup/init script for CentOS.

I’ve coded it to execute the application server inside a screen session. This allows you to easily monitor the application servers output in real-time. This script should be valid for all versions of Adempiere, I’ve tested with 3.6 and 3.7.

[box type="info"] Just note that this document assumes CentOS 6 for all example code and references. Syntax, file locations and codes may vary based on your distribution.[/box]


You’ll need to have the screen package installed, to check run the following:

If the screen package is missing, use yum to install it

Lastly, you’ll need to set $ADM_HOME to your Adempiere directory.


Copy/paste the script into a new file named “/etc/init.d/adempiere”.

You’ll need to make the script executable.

Create all the rc entries, and configure the Adempiere service to boot on system boot

Continue reading…