Init Script not running from PWD
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have installed gunicorn webserver and make gunicorn virtualenv init.d script but when i run service gunicorn start
service from my project directory it works well, But when my present working directory changed such as /root or anyother directory it gives me error. I have edited init script and add following command at start of that script cd /root/demoproject/
script runs from any working directory. What else will be the actual solution other that adding cd /root/demoproject/
command in init script ?
centos init-script
add a comment |Â
up vote
0
down vote
favorite
I have installed gunicorn webserver and make gunicorn virtualenv init.d script but when i run service gunicorn start
service from my project directory it works well, But when my present working directory changed such as /root or anyother directory it gives me error. I have edited init script and add following command at start of that script cd /root/demoproject/
script runs from any working directory. What else will be the actual solution other that adding cd /root/demoproject/
command in init script ?
centos init-script
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have installed gunicorn webserver and make gunicorn virtualenv init.d script but when i run service gunicorn start
service from my project directory it works well, But when my present working directory changed such as /root or anyother directory it gives me error. I have edited init script and add following command at start of that script cd /root/demoproject/
script runs from any working directory. What else will be the actual solution other that adding cd /root/demoproject/
command in init script ?
centos init-script
I have installed gunicorn webserver and make gunicorn virtualenv init.d script but when i run service gunicorn start
service from my project directory it works well, But when my present working directory changed such as /root or anyother directory it gives me error. I have edited init script and add following command at start of that script cd /root/demoproject/
script runs from any working directory. What else will be the actual solution other that adding cd /root/demoproject/
command in init script ?
centos init-script
edited Jun 27 at 8:10
asked Jun 27 at 7:56
blaCkninJa
120111
120111
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
There is nothing wrong with letting the script change its working directory, if it needs to be run with a specific working directory (due to it using relative paths, or whatever it does).
The only thing that one may want to do is to exit with a non-zero exit status if the cd
failed:
cd /root/demoproject || exit 1
You may also change directory in the script depending on the value of an environment variable:
cd "$MY_WORK_DIR:-/root/demoproject" || exit 1
This would change working directory to the directory given by MY_WORK_DIR
, but would default to /root/demoproject
if this variable is empty or unset.
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of addingcd /root/demoproject/
in init script ?
â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
There is nothing wrong with letting the script change its working directory, if it needs to be run with a specific working directory (due to it using relative paths, or whatever it does).
The only thing that one may want to do is to exit with a non-zero exit status if the cd
failed:
cd /root/demoproject || exit 1
You may also change directory in the script depending on the value of an environment variable:
cd "$MY_WORK_DIR:-/root/demoproject" || exit 1
This would change working directory to the directory given by MY_WORK_DIR
, but would default to /root/demoproject
if this variable is empty or unset.
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of addingcd /root/demoproject/
in init script ?
â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
add a comment |Â
up vote
0
down vote
There is nothing wrong with letting the script change its working directory, if it needs to be run with a specific working directory (due to it using relative paths, or whatever it does).
The only thing that one may want to do is to exit with a non-zero exit status if the cd
failed:
cd /root/demoproject || exit 1
You may also change directory in the script depending on the value of an environment variable:
cd "$MY_WORK_DIR:-/root/demoproject" || exit 1
This would change working directory to the directory given by MY_WORK_DIR
, but would default to /root/demoproject
if this variable is empty or unset.
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of addingcd /root/demoproject/
in init script ?
â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
add a comment |Â
up vote
0
down vote
up vote
0
down vote
There is nothing wrong with letting the script change its working directory, if it needs to be run with a specific working directory (due to it using relative paths, or whatever it does).
The only thing that one may want to do is to exit with a non-zero exit status if the cd
failed:
cd /root/demoproject || exit 1
You may also change directory in the script depending on the value of an environment variable:
cd "$MY_WORK_DIR:-/root/demoproject" || exit 1
This would change working directory to the directory given by MY_WORK_DIR
, but would default to /root/demoproject
if this variable is empty or unset.
There is nothing wrong with letting the script change its working directory, if it needs to be run with a specific working directory (due to it using relative paths, or whatever it does).
The only thing that one may want to do is to exit with a non-zero exit status if the cd
failed:
cd /root/demoproject || exit 1
You may also change directory in the script depending on the value of an environment variable:
cd "$MY_WORK_DIR:-/root/demoproject" || exit 1
This would change working directory to the directory given by MY_WORK_DIR
, but would default to /root/demoproject
if this variable is empty or unset.
edited Jun 27 at 8:35
answered Jun 27 at 8:00
Kusalananda
101k13199312
101k13199312
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of addingcd /root/demoproject/
in init script ?
â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
add a comment |Â
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of addingcd /root/demoproject/
in init script ?
â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of adding
cd /root/demoproject/
in init script ?â blaCkninJa
Jun 27 at 8:12
I have edited the question, Actually i want to know Is there anything possible to make env variable instead of adding
cd /root/demoproject/
in init script ?â blaCkninJa
Jun 27 at 8:12
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
@blaCkninJa See updated answer.
â Kusalananda
Jun 27 at 8:35
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452165%2finit-script-not-running-from-pwd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password