event-driven process automation script
Basic IdeaThis is a prove of concept that a basic event-driven business process automation for batch processing, which triggers scripts depending on fulfilled depndencies, is possible just with a few (less than 100 ) lines of shell script code. That is particular usefull if there are only a few (less than 1000 ) jobs that are triggered and no larger overhead is wanted. There are many tools already like but most require not only high license cost but also a staff to maintain the software. With my lightweight open source script framework a single unix admin could maintain it because it is not much more difficult and does not cost more than crontab.
LimitationsOf course because of the light weight inherits has certain limitation. it does not allow not to carry a variable from one process to the next. Currently it does not even handle the current date so that it is not possible yet, to run the same batch for different days at the same time.
DocumentationThe automation engine consist mainly of only two script files (flowcontrol.sh and jobwrapper.sh) and one file (conditionfile.txt) that contains the dependencies between the jobs. (All three files are in one directory which is the engines main directory) The jobs that shall start are in the subdirectory jobs, although that parameter could easily be changed to any other directory in the beginning of the flowcontrol.sh script. The running of the jobs is logged in the subdirectory logs The events that communicate the start or the end of a job are stored as flag files (< jobname >_STARTED and < jobname >_FINISHED) n the subdirectory flags In that directory appear also the two files receivedcondition.txt and processedcondition.txt which are automatically created by the flowcontrol.sh to track which events had been processed already.
InstallationJust unpack the tar file containing the scripts in any directory (for example /opt/edpas ) and add the script that shall be started in the jobs subdiretory. Alternatively change the line JOBDIR= in the flowcontrol.sh to point to the directory with the scripts. Then edit the conditionfile.txt to reflect the dependencies. in the first column goes the predecessor of a job and in the second job itself So the current content 0 1
would result in a flow like Then the flowcontrol.sh has to be started regular and frequently therefore I have added it in the crontab with the following line
0,5,10,15,20,25,30,35,40,45,55 * * * * /opt/edpas/flowcontrol.sh >/dev/null 2>&1
Last but not least I would I have added in the crontab a line to send the first event that would start a daily batch at 1:00 am
0 1 * * * touch /opt/edpas/0_FINISHED
PS.: I forgot the daily clean up
30 0 * * * rm /opt/edpas/*/*
last WordI hope you find it useful. If yes or if you have suggestions for improvement please let me know and write me.