jerry
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
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sweeneydavidj
Hi,
here is a nice article on using Elixir as a scripting language…
https://thoughtbot.com/blog/is-elixir-a-scripting-language
Enjoy
jerry
Hi @sweeneydavidj,
Thanks for your response.
I had read and tried the steps outlined in the guide ealier before my post here.
Below is the error I get when I attempt to run the standalone script with mix:
13:06:27.160 [error] Failed to start Ranch listener Test.Router.HTTP in :ranch_tcp:listen([cacerts: :…, key: :…, cert: :…, port: 80, ip: {0, 0, 0, 0}]) for reason :eaddrinuse (address already in use)
13:06:27.180 [info] Application test exited: Test.Application.start(:normal, ) returned an error: shutdown: failed to start child: {:ranch_listener_sup, Test.Router.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Test.Router.HTTP, :eaddrinuse}
** (Mix) Could not start application test: Test.Application.start(:normal, ) returned an error: shutdown: failed to start child: {:ranch_listener_sup, Test.Router.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Test.Router.HTTP, :eaddrinuse}
NobbZ
Your cron seems to want to start the application a second time, rather than to communicate with it, therefore
ranchcan’t boot, as the port it wants to listen on, is already in use by your main instance of the application.If you use
distilleryjust use a custom task, if you are using 1.9-releases, use their equivalent, if you usemix(as a command via cron) then make sure to use--no-start(IIRC), if you use anescriptmake sure it does not start the application and its dependencies, but just loads them.jerry
Hello @NobbZ,
Thanks for the response.
It worked for me.
I, however, have another issue still pertaining to this same activity.
When the function that has been invoked by the standalone script from a module in the main project has some Ecto processes to run,
I get the error below:
** (ArgumentError) repo Test.Repo is not started, please ensure it is part of your supervision tree
lib/ecto/query/planner.ex:148: Ecto.Query.Planner.query_lookup/6
lib/ecto/query/planner.ex:131: Ecto.Query.Planner.query_with_cache/7
lib/ecto/repo/queryable.ex:124: Ecto.Repo.Queryable.execute/5
lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
lib/test/transactions.ex:387: Test.Transaction.process_staged_requests/0
scripts/staged_requests.exs:5: (module)
I would be grateful once again for your assistance.
Thanks.
Jerry
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
quantumand trigger the task from within your application.jerry
Thanks very much, @NobbZ.
I’ll go ahead and use Quantum instead.
Regards,
Jerry