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
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).
2
Popular in Questions
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
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
I would like to know what is the best IDE for elixir development?
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
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
Other popular topics
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
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
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New







