# Error with setting TZ=UTC when running touch in Julia

**URL:** <https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315>\
**Category:** General Usage\
**Tags:** question, shell, cmd\
**Created:** [December 8, 2023, 5:27am UTC](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315 "2023-12-08T05:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeepLearning](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@KeepLearning](https://discourse.julialang.org/u/KeepLearning)\
**Post date:** [December 8, 2023, 5:27am UTC](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315/1 "2023-12-08T05:27:24Z")

</div>

Hi,

I wanted to run the unix command in Julia as follows:

```julia
run(`TZ=UTC touch -t "YYMMDDhhmm" filename`)

```

but got an IOError, assuming that I am in a different time zone from UTC and wanted to set the timestamp of a file in UTC. The above works without TZ=UTC, but the timestamp is set according to my local time zone.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [December 8, 2023, 10:03am UTC](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315/2 "2023-12-08T10:03:47Z")

</div>

The Cmd literal is not spawning a shell, it spawns processes directly. Prepending environment variables like that is a feature of your shell, not of spawning a process. To influence environment variables of spawned processes, use [`addenv`](https://docs.julialang.org/en/v1/base/base/#Base.addenv).

---

<div class="post-metadata">

**Author:** ![KeepLearning](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@KeepLearning](https://discourse.julialang.org/u/KeepLearning)\
**Post date:** [December 11, 2023, 2:32am UTC](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315/3 "2023-12-11T02:32:47Z")

</div>

Thanks!, I made it by using the following:

```julia
run(addenv(`touch -t "YYMMDDhhmm" filename`, "TZ" => "UTC"));

```
