Building a Visualized Scheduled Task with jiacrontab

Publish: 2018-11-20 | Modify: 2018-11-20

If you have used Windows Task Scheduler or Linux's crontab, then the term "scheduled task" may not be unfamiliar to you. In short, it refers to executing a task at a set time or cyclically based on conditions. In Linux, crontab needs to be operated through the command line, but with jiacrontab, you can create scheduled tasks through a web interface, which is much simpler than using crontab directly.

Main Features of jiacrontab

  1. Allows setting a timeout for each script, with options to notify the administrator by email or forcefully kill the script process when it times out.
  2. Allows setting the maximum concurrency of scripts.
  3. Allows one server to manage multiple clients.
  4. Each script can be flexibly configured on the server side, such as running test scripts, viewing logs, killing processes, stopping scheduling, etc.
  5. Allows adding script dependencies (supports cross-server), with options for synchronous and asynchronous execution modes for dependent scripts.
  6. User-friendly web interface for easy operation.
  7. Can send email notifications to multiple recipients when a script encounters an error.
  8. Supports persistent tasks and can be configured to automatically restart failed tasks.
  9. Supports pipeline operations.

Running Principle

  • jiacrontab consists of two parts: the server and the client, which communicate with each other through RPC.
  • Server: provides a visual interface for users and schedules multiple clients.
  • Client: implements the scheduling logic, isolates user scripts, and can be deployed on multiple servers for unified management by the server. The scheduling format for each script is fully compatible with the crontab script configuration format of Linux itself.

Installing jiacrontab on Linux

jiacrontab is developed in Golang, and the author has provided pre-compiled binary packages, which can be downloaded and used directly, making it very convenient.

# Install unzip
yum -y install unzip
# Download jiacrontab
wget https://jiacrontab.iwannay.cn/download/jiacrontab-v1.4.5-linux-amd64.zip
# If the download speed is slow, you can replace it with the xiaoz software library address
wget http://soft.xiaoz.org/linux/jiacrontab-v1.4.5-linux-amd64.zip
# Unzip
unzip jiacrontab-v1.4.5-linux-amd64.zip
# Run the server
cd app/jiacrontab/server
nohup ./jiaserver &> jiaserver.log &
# Run the client
cd app/jiacrontab/client
nohup ./jiaclient &> jiaclient.log &

Allow access to the ports. The jiacrontab server and client listen on ports 20000 - 20003. Run the following command to allow access:

# Allow ports in firewalld
firewall-cmd --zone=public --add-port=20000-20003/tcp --permanent
firewall-cmd --reload
# If using iptables
iptables -I INPUT -p tcp --dport 20000 -j ACCEPT
iptables -I INPUT -p tcp --dport 20001 -j ACCEPT
iptables -I INPUT -p tcp --dport 20002 -j ACCEPT
iptables -I INPUT -p tcp --dport 20003 -j ACCEPT
iptables save
service iptables restart

Then access http://IP:20000 to see the jiacrontab web interface. The initial username is admin and the password is 123456.

Configuration Files

  • The server configuration file is located at server/server.ini, which includes username, password, SMTP settings, etc. It is recommended to modify it.
  • The client configuration file is located at client/client.ini, mainly for modifying the default email recipient for alarms.
  • After modifying the files, you need to kill the corresponding processes and then rerun them using the nohup command.

Other Notes


Comments