# Run code hourly

**URL:** <https://forum.universal-robots.com/t/run-code-hourly/22194>\
**Category:** Technical Questions\
**Created:** [June 23, 2022, 6:47pm UTC](https://forum.universal-robots.com/t/run-code-hourly/22194 "2022-06-23T18:47:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mike](https://forum.universal-robots.com/u/mike)\
**Post date:** [June 23, 2022, 6:47pm UTC](https://forum.universal-robots.com/t/run-code-hourly/22194/1 "2022-06-23T18:47:46Z")

</div>

I’m looking to have some code, write some variables to the log file hourly. A crude parts counter.

IE each hour on the hour, write the date/time/value of 4 variables and reset the variables. Preferably something similar to a cron job. Or, if it needs to run as a thread that’s fine also.

Does anyone have some sample code the can share?

---

<div class="post-metadata">

**Author:** ![MikeM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mikem/32/3114_2.png) [@MikeM](https://forum.universal-robots.com/u/MikeM)\
**Post date:** [June 24, 2022, 1:17am UTC](https://forum.universal-robots.com/t/run-code-hourly/22194/2 "2022-06-24T01:17:11Z")

</div>

Very do-able, unfortunately I can’t share any code. Might want to output it somewhere else though if you plan to make this a permanent solution (like a csv file or something, just a suggestion).

With a little bit of URscript and a thread you should be able to achieve this.

There is also a urcap developed by the genius @jbm here [Get Controller Time URcap](https://forum.universal-robots.com/t/urcap-sample-get-controller-time-in-urscript/1256) this will give you better time stamps from the controller.

**Like any PC the clock will drift over time, probably make it a weekly habit go into the UR system settings and update the clock**

Someone else in the community may be able to provide better guidance or a programmed solution, anyways hope this helps get you started and best of luck!

---

<div class="post-metadata">

**Author:** ![g.mat](https://avatars.discourse-cdn.com/v4/letter/g/ea5d25/32.png) [@g.mat](https://forum.universal-robots.com/u/g.mat)\
**Post date:** [September 5, 2023, 1:37pm UTC](https://forum.universal-robots.com/t/run-code-hourly/22194/3 "2023-09-05T13:37:14Z")

</div>

@mike ,

Were you able to find a way to accomplish this? If so, do you have example code that you could share?
