Cronicle icon indicating copy to clipboard operation
Cronicle copied to clipboard

Multiplex job environmental variables

Open lgwapnitsky opened this issue 6 months ago • 3 comments

I have a job that needs to run on multiple systems repeatedly, but each system has a specific environmental variable that needs to be set when the job is run. Currently I have four separate jobs, but would like to combine this into one multiplex job. Is there a way I can set this environmental variable per host when running the multiplex job?

lgwapnitsky avatar Feb 11 '24 13:02 lgwapnitsky

I'm so sorry, but this feature does not exist. I cannot think of a way to achieve it with Cronicle. I will add this as a feature request.

jhuckaby avatar Feb 12 '24 05:02 jhuckaby

Hey, no problem. So far, it's a great app. I appreciate the work that's been done already

On Mon, Feb 12, 2024, 00:35 Joseph Huckaby @.***> wrote:

I'm so sorry, but this feature does not exist. I cannot think of a way to achieve it with Cronicle. I will add this as a feature request.

— Reply to this email directly, view it on GitHub https://github.com/jhuckaby/Cronicle/issues/720#issuecomment-1938087784, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE6CFETTH36EPQ3YWG5IH3YTGSZPAVCNFSM6AAAAABDDQZ4K6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGA4DONZYGQ . You are receiving this because you authored the thread.Message ID: @.***>

lgwapnitsky avatar Feb 12 '24 12:02 lgwapnitsky

You can achieve this by using the shell plugin and some if-then clauses:

#!/bin/bash

export VAR=0
if [[ $(hostname -a) == "server01" ]]; then
	export VAR=1
fi

if [[ $(hostname -a) == "server02" ]]; then
	export VAR=2
fi

if [[ $(hostname -a) == "server03" ]]; then
	export VAR=3
fi

echo $VAR

works for me. depending on the executing server, the correct variable is output.