Linux Task Execution Automation
We have a set of 11 linux servers that function as our VMware hosts. While these systems are not necessarily all the same hardware, they need to look identical as it relates to software and kernel versions. I’ve been working on system to automate the tasks done on these machines. What I’ve come up with has so far and will work pretty well.
On each host there is a simple script, which runs every 5 minutes, that grabs another script from a central location. The script sleeps for a random amount of time (to keep load down on the MySQL server), checks a database for tasks to run, compares the id of the tasks against a local file with tasks already run, if it hasn’t run them, it runs them.
The database is really simple. It consists of one table with three columns: id, task to run, and a timestamp (possible future functionality). When a task is added to the database, it is executed within 5 minutes on all 11 hosts. I’ve included the scripts below.
Simple host script connectcontrol.py
Centrally stored control script controlscript.py
Tags: automation, cron, linux, MySQL, python
You can comment below, or link to this permanent URL from your own site.