Finally got it working. Here is the steps done in my computer (running OSX), it might change a little bit if you use Linux.
I’ve created a script with the following code:
#!/bin/bash
cd /path/project
mix phx.server&
And run with the following line on crontab:
*/1 * * * * /tmp/test.sh >> /var/log/crontab.log 2>&1
The output of crontab.log was showing this:
/tmp/test.sh: line 2: mix: command not found
Using the full path of mix didn’t solve it. (/usr/local/bin/mix phx.server)
env: elixir: No such file or directory
Searching that on google, I found an comment from José Valim, Ability to use elixir commands that shipped as an application dependency · Issue #789 · elixir-lang/elixir · GitHub
But even using /usr/local/bin/elixir /usr/local/bin/mix phx.server & didn’t solve it, because it gave the following error:
/usr/local/bin/elixir: line 123: exec: erl: not found
So, if you output the $PATH, you will see that only have 2 directories (or less than you expected): /usr/bin:/bin
You can check where is your binaries, with the command which, like which elixir. You will need in your path at least for mix, elixir and erl.
In the final script, you should export PATH concatenating the missing path, in my case was /usr/local/bin/.
export PATH=$PATH:/usr/local/bin/
After that you should be able to run any command with mix, you don’t need the full path.






















