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

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
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
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

Other popular topics 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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
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
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
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