Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:17:12+00:00 2026-06-08T12:17:12+00:00

I’m looking for any way for clojure that can trigger an event at a

  • 0

I’m looking for any way for clojure that can trigger an event at a given time,

For example: I want a particular process to start at 9:30am and then I can trigger another process to start running half an hour later etc.

Thanks in advance!


Updated 2:

Thanks @arthur-ulfeoldt and @unknown-person who also suggested using https://github.com/samaaron/at-at before deleting his answer. The documentation is a little out of date but here’s how I got going.

(use 'overtone.at-at)

(def my-pool (mk-pool))
;=> make a thread pool

(every 1000 #(println "I am super cool!") my-pool :initial-delay 2000) 
;=> starts print function every 1 sec after a 2 sec delay

(stop *1) 
;=> stops it

So to make it start at exactly 9, with an interval of half an hour, I would do:

(require '[clj-time.core :as t])
(require '[clj-time.coerce :as c])
(use 'overtone.at-at)

;Make Thread Pool
(def my-pool (mk-pool))

(def current-time (t/now))

(def current-date (t/date-time 
                    (t/year current-time)
                    (t/month current-time)
                    (t/day current-time)))

(def next-9-oclock
  (if (> 9 (t/hour current-time))
    (t/plus current-date (t/hours 9))
    (t/plus current-date (t/days 1) (t/hours 9))))

(def initial-delay
   (- (c/to-long next-9-oclock) (c/to-long current-time))

(every 1800000 
       #(println "I am super cool!") 
       my-pool 
       :initial-delay 
       initial-delay) 

Updated:

@arthur-ulfeoldt, I am not sure how to translate some of the java code into clojure.
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html

like:

final ScheduledFuture<?> beeperHandle = 
        scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);

and:

final Runnable beeper = new Runnable() {
        public void run() { System.out.println("beep"); }
     };

Entire Example

 class BeeperControl {
    private final ScheduledExecutorService scheduler = 
       Executors.newScheduledThreadPool(1);

    public void beepForAnHour() {
        final Runnable beeper = new Runnable() {
                public void run() { System.out.println("beep"); }
            };
        final ScheduledFuture beeperHandle = 
            scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
        scheduler.schedule(new Runnable() {
                public void run() { beeperHandle.cancel(true); }
            }, 60 * 60, SECONDS);
    }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:17:13+00:00Added an answer on June 8, 2026 at 12:17 pm

    I needed something that

    • started scheduled tasks at whole-second intervals as opposed to whole minute intervals having high system-time accuracy.
    • would spawn as many threads as needed, so that tasks started at earlier intervals could exist along side tasks started at later intervals.

    After doing a bit of source code reading for at-at, Monotony and Quartzite, I felt that they did not fit the requirements that I was after (which was really something more bare bone) so I wrote my own – cronj

    An example of the usage.

    (require '[cronj.core :as cj])
    
    (cj/schedule-task! {:id 0   :desc 0 
                  :handler #(println "job 0:" %) 
                  :tab "/5 * * * * * *"}) ;; every 5 seconds
    (cj/schedule-task! {:id 1   :desc 1 
                  :handler #(println "job 1:" %) 
                  :tab "/3 * * * * * *"}) ;; every 3 seconds
    
    (cj/start!) 
    
    ;; wait for scheduler to do its thing ......
    
    (cj/stop!)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.