# Set an environment variable depending on cycle

**URL:** <https://cylc.discourse.group/t/set-an-environment-variable-depending-on-cycle/1052>\
**Category:** Cylc Support\
**Created:** [November 5, 2024, 10:31am UTC](https://cylc.discourse.group/t/set-an-environment-variable-depending-on-cycle/1052 "2024-11-05T10:31:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gturek](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@gturek](https://cylc.discourse.group/u/gturek)\
**Post date:** [November 5, 2024, 10:31am UTC](https://cylc.discourse.group/t/set-an-environment-variable-depending-on-cycle/1052/1 "2024-11-05T10:31:24Z")

</div>

Hi. I’d like to set environment variable FIRST\_CYCLE = true if I am running in the 1st cycle, and set it to false in subsequent cycles. What is the best way to do this?  
Thanx!

---

<div class="post-metadata">

**Author:** ![MetRonnie](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/metronnie/32/125_2.png) [@MetRonnie](https://cylc.discourse.group/u/MetRonnie)\
**Post date:** [November 5, 2024, 11:01am UTC](https://cylc.discourse.group/t/set-an-environment-variable-depending-on-cycle/1052/2 "2024-11-05T11:01:15Z")

</div>

There is a list of environment variables available in job scripts here: [Job Script Environment Variables — Cylc 8.3.4 documentation](https://cylc.github.io/cylc-doc/latest/html/reference/job-script-vars/index.html)

So you would want something like this

```bash
if [["$CYLC_TASK_CYCLE_POINT" == "$CYLC_WORKFLOW_INITIAL_CYCLE_POINT"]]; then
    ...

```

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [November 5, 2024, 9:16pm UTC](https://cylc.discourse.group/t/set-an-environment-variable-depending-on-cycle/1052/3 "2024-11-05T21:16:10Z")

</div>

Depending on requirements, you can also handle different behaviour in the first cycle with a different graph structure. E.g.:

```ini
[scheduling]
    cycling mode = integer
    initial cycle point = 1
    [[graph]]
        R1 = "foo1" # once at first cycle
        R/2/P1 = "foo" # every cycle from 2
[runtime]
    [[foo1, foo]]
        script = "echo my name is $CYLC_TASK_NAME"

```
