jerry

jerry

Elixir standalone script in a Linux cron

Hello,

Is there a way I can write an elixir script and schedule it in a Linux cron job to perform some repetitive tasks?

I would like the script to invoke some Ecto functions from modules defined inside an Elixir mix project.

Any help would be most appreciated.

Thanks.

Jerry

Most Liked

NobbZ

NobbZ

Your cron seems to want to start the application a second time, rather than to communicate with it, therefore ranch can’t boot, as the port it wants to listen on, is already in use by your main instance of the application.

If you use distillery just use a custom task, if you are using 1.9-releases, use their equivalent, if you use mix (as a command via cron) then make sure to use --no-start (IIRC), if you use an escript make sure it does not start the application and its dependencies, but just loads them.

NobbZ

NobbZ

Well, you need to start your ecto repository without the rest of the application.

Be aware that it might then crash as well, as dependencies for ecto might be missing.

To be honest, the easiest thing is probably to use quantum and trigger the task from within your application.

sweeneydavidj

sweeneydavidj

Hi,
here is a nice article on using Elixir as a scripting language…
https://thoughtbot.com/blog/is-elixir-a-scripting-language
Enjoy :slight_smile:

Last Post!

jerry

jerry

Thanks very much, @NobbZ.

I’ll go ahead and use Quantum instead.

Regards,

Jerry

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement