Resources for running julia routines in the background 24/7

If you just want to run your routines at specific time during the day, cron is perfectly well suited for this.

If, on other hand, you really need to run some Julia code 24/7 (e.g. web server), it’s worth to turn it into a system service using something like systemd. It may sound complicated, but in fact boils down to a one small file and a couple of Linux commands.

Sometimes one of these other functions might not achieve what they’re supposed to, since they’ll be interacting with the internet, so I would also need to be able to have the facility to tell the main routine to wait and try again in a couple of seconds or two if that happens.

Just run in try-catch block, it works well in practice. E.g.:

result = nothing
done = false
while !done
    try 
        result = # invoke function that may fail
        done = true
    catch e
        sleep(5)  # sleep for 5 seconds before restarting
     end
end
1 Like