script

script

Crontab issue for running script to start server

I am on ec2 instance ubuntu server and playing around with bash scripting. I have a very simple script which runs when the server reboots.

 cd /home/ubuntu/d/web

echo  "Start Phoenix server"** > server.log

whoami > server.log

date >> server.log

pwd >> server.log

source .env

mix phx.server >> server.log 2>&1

I got this error after the server reboots.

/home/ubuntu/startPhoenix.sh: 7: mix: not found

It works fine until the mix phx.server line.

I have this line in crontab -e file

 @reboot /home/ubuntu/startPhoenix.sh

If I run the script like this, it works fine.

              ./startPhoenix.sh 

What I don’t understand is why I am getting mix not found error.

I am using asdf for version control.

Any hint will be much appreciated.

Thanks.

Most Liked

hauleth

hauleth

Cron do not set PATH so it doesn’t know where mix is.

However I would suggest you to use releases for production deployments instead of running mix phx.server and to start such release via systemd (or other system supervisor of your choice).

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement