Running a specific julia environment from a crontab

Hi there.

My goal is to run a Julia script from crontab.

For this I need to be able to activate the correct Julia environment from the command line. I’m not sure how to do this.

A possible solution I’ve found is to add code to the startup.jl such as:

using Pkg
if isfile("Project.toml") && isfile("Manifest.toml")
    Pkg.activate(".")
end

Is this an appropriate/best solution?

You can do:

julia --project=/path/to/your/project/folder script.jl

to run script.jl using the given environment.

4 Likes

In addition to @rdeits answer, you may also want to check out DaemonMode.jl by @dmolina. It was designed with crontab use in mind. :slight_smile:

Ah, nice. Much simpler!