CentralGo : A Multithreaded Scheduling Tool For Running Routine Tasks
Recently I started coding a tool that I needed to schedule the execution of some script (locally and remotely). The idea is to create a crontab like tool, based on python and taking advantage of its strength. This tool development is in progress and if you’re interested to contribute see the github page. You can fork and push your code, open a bug ticket or make suggestions.
CentralGo let you set up a central system to execute and schedule jobs on your local machine or other machines while having all jobs, logs and configurations in a single server.
Run routine tasks
Like checking if a website is up or down every 5 minutes, testing response time twice a day, backups.. etc
Schedule tasks with email notification
Add your email address in the job definition and you’ll be notified if something goes wrong
Keep logs on scheduled tasks
Debug what you’re doing
Replace your system crontab with a user-friendly definition language
Job definition is quite easy
CentralGo runs as a daemon and it is configured to log events. User should choose the logging level.
Its quite simple, not yet scripted, do it manually like this. I am using sudo here to run as root, adapt this to your distribution:
#Get the zip archive from github repos. sudo wget https://github.com/eon01/centralGo/archive/master.zip -O CentralGo.zip; unzip CentralGo.zip; rm CentralGo.zip; mv centralGo-master CentralGo; #Create a directory under /opt/ and move on all of our scripts sudo mkdir /opt/CentralGo; cd CentralGo; sudo cp * /opt/CentralGo; #Create a symbolic link in /usr/bin to make our program "callable" directly from CLI. sudo ln -s /opt/CentralGo/centralgo.py /usr/bin/centralgo
Two files to configure :
The first one will help you to set up jobs and schedule them. This will be explained later in this post.
The second one will set up the general configuration of CentralGo.
Here is an example:
[mailing] activate = True from = firstname.lastname@example.org smtp_server = smtp.eon01.com smtp_port = 9922 user_name = admin password = my_password [logging] level = info
Sending emails will notify you about jobs that encounter a problem. An email will be sent to you to the email address configured in jobs.conf
For that reason you should set activate to True and configure the other options.
The logging section concerns the level of logging, three values are possible:
“info” means: log everything – “warning” means: logs info and warnings – “error” means: log only errors
Just add a similar line to jobs.conf :
define "MyJob" run "echo 'I am the job number 0'" every "1 seconds" notify "email@example.com";
define "MyJob" run "script.sh" every "sunday at 23:55" notify "firstname.lastname@example.org"
here is the general structure
define <jobname> run <script or command> every <x second | day at xx:xx | dayname at xx:xx> notify <your email>
After setting up your configuration, you can start CentralGo:
This will start a daemon and start logging.
-Support remote execution (handling ssh without being obliged to declare it in the <command> (jobs.conf)
-Some bugs were discovered in setup.sh
-Add package to pip
You can suggest to add something else to the Todo List, or contribute to the code using github : https://github.com/eon01/centralGo