This program looks through a chosen folder for shell scripts (files ending in *.sh). It finds scheduling details inside each script and runs them at the set times. It helps to arrange tasks that need to run regularly, set up their times directly in the scripts, and run them automatically using Go.
Before running the program, follow these steps to set it up:
- Clone the repository: Open your command line or terminal and run the following command to clone the Git repository:
git clone https://github.com/JexSrs/go-shellcron.git
- Navigate into the project directory: After cloning, change into the project directory:
cd go-shellcron
- Install necessary Go package:
Install the
cron
package required for scheduling tasks:
go mod tidy
After these setup steps, the program will be ready for use.
Before using Docker, ensure Docker is installed on your system. Visit Docker's official installation guide for help with the installation.
-
Pull the Docker Image: Pull the latest image of your project directly from GitHub Container Registry:
docker pull ghcr.io/jexsrs/go-shellcron:latest
-
Run your Docker Container: Run the Docker container using the image pulled from GHCR with the following command:
docker run --name go-shellcron -v $(pwd)/scripts:/scripts -d ghcr.io/jexsrs/go-shellcron:latest
For an even simpler setup or deployment, you can utilize Docker Compose.
-
Create a
docker-compose.yml
file: Make sure you have adocker-compose.yml
file in the root of your project with the following content. Note that thebuild
option is replaced by directly using the image from GHCR:services: go-shellcron: image: ghcr.io/jexsrs/go-shellcron:latest restart: always volumes: - ./scripts:/scripts
-
Run using Docker Compose: To start your services using Docker Compose, run:
docker-compose up -d
Here is a sample script to be processed by this scheduler:
#!/bin/bash
#CRON: */10 * * * *
# Echo current date and time
echo "Current date and time:"
date
The script above is scheduled to run every 10 minutes.
Contributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request for review.
This project is licensed under the MIT License - see the LICENSE file for details.