My crontab file looks like:
*/1 * * * * /Users/dmitriy/.asdf/shims/elixir ~/work/scripts/my_script.exs
And that script doesn't work. As I understand it, cron cannot detect the location of elixir. I run it on macOs Ventura.
How can I solve this problem?
I'm on
macOS 12.5.1, and I have elixir installed with asdf as well. My path to elixir is the same as yours but with my user name instead:I used a full path to my elixir script:
my_prog.ex contains:
I redirected the output of stdout and stderr from the elixir script to a log file (>> is append):
Here is what I see in
cron_output.log:It looks like erl, i.e. the erlang command, can't be found.
I also have python installed with asdf, and it has the same path as elixir but with python instead of the word elixir. Here's a cron job for python:
Here's my python program
1.py:Output in cron_output.log:
The interplay between elixir and erlang seems to be the problem with scheduling elixir scripts.
This worked for me:
The last part:
just redirects stdout and stderr to a log file. You don't have to do that. I get system mail if there are errors when executing the cronjob or if there is unhandled output: