# How to call a function after 10 minutes or second?

**URL:** <https://www.ruby-forum.com/t/how-to-call-a-function-after-10-minutes-or-second/190127>\
**Category:** Rails\
**Created:** [June 16, 2010, 12:43pm UTC](https://www.ruby-forum.com/t/how-to-call-a-function-after-10-minutes-or-second/190127 "2010-06-16T12:43:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vuonghung12a2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ce7236/32.png) [@vuonghung12a2](https://www.ruby-forum.com/u/vuonghung12a2)\
**Post date:** [June 16, 2010, 12:43pm UTC](https://www.ruby-forum.com/t/how-to-call-a-function-after-10-minutes-or-second/190127/1 "2010-06-16T12:43:20Z")

</div>

Hi all,

I have a problem.

I want to call some function after every 10 minutes. But I don’t it.

---

<div class="post-metadata">

**Author:** ![vuonghung12a2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ce7236/32.png) [@vuonghung12a2](https://www.ruby-forum.com/u/vuonghung12a2)\
**Post date:** [June 16, 2010, 12:53pm UTC](https://www.ruby-forum.com/t/how-to-call-a-function-after-10-minutes-or-second/190127/2 "2010-06-16T12:53:46Z")

</div>

Vuong H. wrote:

> Hi all,
> 
> I have a problem.
> 
> I want to call some function after every 10 minutes. But I don’t it.

JavaScript functions can be used for this effect in most instances.  
Though it depends on which function you want to execute, of course.

---

<div class="post-metadata">

**Author:** ![vuonghung12a2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ce7236/32.png) [@vuonghung12a2](https://www.ruby-forum.com/u/vuonghung12a2)\
**Post date:** [June 16, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/how-to-call-a-function-after-10-minutes-or-second/190127/3 "2010-06-16T17:27:24Z")

</div>

Vuong H. wrote:

> Hi all,
> 
> I have a problem.
> 
> I want to call some function after every 10 minutes. But I don’t it.

Please provide more detail. Are you asking about server-side or  
client-side?

If you are asking about server-side there are options like delayed\_job:

> **[GitHub - collectiveidea/delayed\_job: Database based asynchronous priority...](https://github.com/collectiveidea/delayed_job)**
>
> Database based asynchronous priority queue system -- Extracted from Shopify - GitHub - collectiveidea/delayed\_job: Database based asynchronous priority queue system -- Extracted from Shopify

Or, in case the action to perform is very simple you can use use  
something like curl to send requests periodically to a url using cron:

$ crontab -e  
\*/10 \* \* \* \* curl [http://example.com/action](http://example.com/action)

If you’re talking about client-side (JavaScript) then there are timing  
events that you can use for delayed or repeating events:

> **[JavaScript Timing Events](https://www.w3schools.com/js/js_timing.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

If you’re using the Prototype JavaScript library it provides the  
Ajax.PeriodicalUpdater if you want to repeatedly send a request on an  
interval.

[http://api.prototypejs.org/ajax/ajax/periodicalupdater/](http://api.prototypejs.org/ajax/ajax/periodicalupdater/)
