erlang中是否有在给定时间后自动被调用的函数,一旦被触发,应在给定时间后自动被调用,因此无需再次触发它。我正在写erlang中的一个模块,可以在ejabberd服务器上执行清理任务。该模块一旦触发,就需要每天自动调用。任何指针
apply_after, send_after
,允许在一定时间后执行功能或发送消息,apply_interval, send_interval
允许定期执行功能或发送消息。结合了apply_after和apply_interval或发送间隔,您应该能够做您想做的。
timer:apply_after/4
。示例:
-module(my_module).
-export([foo/1]).
foo(Text) ->
error_logger:info_msg(Text, []).
在10000毫秒后调用foo:
timer:apply_after(10000, my_module, foo, ["Hello!"]).