Why is my bash script terminating?How to determine if a bash variable is empty?Bash script: check a list of...

How to lift/raise/repair a segment of concrete slab?

Woman in friend circle telling people I "should be fired"

Can we carry rice to Japan?

Why can't we make a perpetual motion machine by using a magnet to pull up a piece of metal, then letting it fall back down?

Levi-Civita symbol: 3D matrix

Get length of the longest sequence of numbers with the same sign

Where is the line between being obedient and getting bullied by a boss?

What is better: yes / no radio, or simple checkbox?

In Adventurer's League, is it possible to keep the Ring of Winter if you manage to acquire it in the Tomb of Annihilation adventure?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Toast materialize

Impact on website analytics caused by accessibility issues

Didactic impediments of using simplified versions

Why is it "take a leak?"

Is the withholding of funding notice allowed?

Do higher etale homotopy groups of spectrum of a field always vanish?

Real life puzzle: Unknown alphabet or shorthand

Dystopian novel where telepathic humans live under a dome

What does @RC mean in SSDT SQL Server Unit Testing?

What am I? I am in theaters and computer programs

VAT refund for a conference ticket in Sweden

How to kill a localhost:8080

Is there a math equivalent to the conditional ternary operator?

Book about a time-travel war fought by computers



Why is my bash script terminating?


How to determine if a bash variable is empty?Bash script: check a list of commandsExecute a Perl script after reboot on Solaris 10how to execute bash script with crontab in centos?CentOS root user crontab for mysqldumpRunning a bash script via cronjob to restart a servicePressing Ctrl-C stops bash script, but don't stop PHP script called by the scriptUpstart, node and bash usersHow to make a bash script wait after running SSH command?Unable to run bash script on EC2 start-up













0















I have a node app running on my Linux hosting server.



Sometimes the app crashes and I need to restart it, so I log in and type these commands:



pkill node
cd public_html/n49900_dpndev
node server.js &


And the app runs again.



Now I would like to put this into a script so I simply need to start the script (or can execute it from a PHP script, for instance).



I created a file called "startnode":



#!/bin/bash
pkill node
cd public_html/n49900_dpndev
node server.js &


I changed the permissions with chmod 755 startnode.



But when I execute it with ./startnode it responds with:




Terminated




What do I need to do so that the commands I type in manually also work in the bash script?










share|improve this question























  • Why don't you just make a systemd unit?

    – Michael Hampton
    8 mins ago
















0















I have a node app running on my Linux hosting server.



Sometimes the app crashes and I need to restart it, so I log in and type these commands:



pkill node
cd public_html/n49900_dpndev
node server.js &


And the app runs again.



Now I would like to put this into a script so I simply need to start the script (or can execute it from a PHP script, for instance).



I created a file called "startnode":



#!/bin/bash
pkill node
cd public_html/n49900_dpndev
node server.js &


I changed the permissions with chmod 755 startnode.



But when I execute it with ./startnode it responds with:




Terminated




What do I need to do so that the commands I type in manually also work in the bash script?










share|improve this question























  • Why don't you just make a systemd unit?

    – Michael Hampton
    8 mins ago














0












0








0








I have a node app running on my Linux hosting server.



Sometimes the app crashes and I need to restart it, so I log in and type these commands:



pkill node
cd public_html/n49900_dpndev
node server.js &


And the app runs again.



Now I would like to put this into a script so I simply need to start the script (or can execute it from a PHP script, for instance).



I created a file called "startnode":



#!/bin/bash
pkill node
cd public_html/n49900_dpndev
node server.js &


I changed the permissions with chmod 755 startnode.



But when I execute it with ./startnode it responds with:




Terminated




What do I need to do so that the commands I type in manually also work in the bash script?










share|improve this question














I have a node app running on my Linux hosting server.



Sometimes the app crashes and I need to restart it, so I log in and type these commands:



pkill node
cd public_html/n49900_dpndev
node server.js &


And the app runs again.



Now I would like to put this into a script so I simply need to start the script (or can execute it from a PHP script, for instance).



I created a file called "startnode":



#!/bin/bash
pkill node
cd public_html/n49900_dpndev
node server.js &


I changed the permissions with chmod 755 startnode.



But when I execute it with ./startnode it responds with:




Terminated




What do I need to do so that the commands I type in manually also work in the bash script?







linux bash node.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 17 mins ago









Edward TanguayEdward Tanguay

46131324




46131324













  • Why don't you just make a systemd unit?

    – Michael Hampton
    8 mins ago



















  • Why don't you just make a systemd unit?

    – Michael Hampton
    8 mins ago

















Why don't you just make a systemd unit?

– Michael Hampton
8 mins ago





Why don't you just make a systemd unit?

– Michael Hampton
8 mins ago










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f956924%2fwhy-is-my-bash-script-terminating%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f956924%2fwhy-is-my-bash-script-terminating%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

Маріан Котлеба Зміст Життєпис | Політичні погляди |...