PremoWeb / chadburn

Chadburn is a scheduler alternative to cron, built on Go and designed for Docker environments.
MIT License
36 stars 4 forks source link

How to list all chadburn job with time #60

Closed xspio closed 8 months ago

xspio commented 1 year ago

It can be seen in command line or logs for convenient task management

maietta commented 1 year ago

I'm not sure what your question is, exactly.

If you've applied labels to your containers, you can export them with docker commands. You could use a bash script like what's below to list out your scheduled jobs by their labels prefixed with "chadburn".


# List all container IDs (including stopped ones)
container_ids=$(docker ps -aq)

# Iterate through each container ID and export its labels
for container_id in $container_ids; do
    # Use docker inspect to get container metadata in JSON format and then extract labels
    labels=$(docker inspect -f '{{json .Config.Labels}}' $container_id)

    # Check if labels contain any key starting with "chadburn"
    if [[ $labels == *\"chadburn* ]]; then
        # Print the container ID and its labels
        echo "Container ID: $container_id"
        echo "Labels: $labels"
    fi
done
maietta commented 1 year ago

As a follow-up, you could export with a one-liner:

docker ps -aq --format '{{.ID}}' | xargs -I {} docker inspect --format='{{.ID}}: {{.Config.Labels}}' {} | grep ': chadburn'
xspio commented 1 year ago

my bad, just a list of all runing jobs, including docker labels and chadburn config file