Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to run multiple background processes through ssh, aggregate all outputs and errors to the same file and redirect the logs to papertrail using remote_syslog
Following this answer i execute a ruby script in background like this :
ssh deploy#xx.xx.xxx.xx 'cd path/to/my_app; nohup ruby my_script.rb > log/script.log 2> log/script.log < /dev/null &'
It works as long as i only run one script. If i run multiple scripts i only see the output of the first script in the log file.
Can you explain what i'm doing wrong ? Or provide a better way to achieve this. Thanks !
(the log file is in path/to/my_app/log/script.log)
Solution :
Thanks to devnull comment i solved it, it was so simple... The proper command is :
ssh deploy#xx.xx.xxx.xx 'cd path/to/my_app; nohup ruby my_script.rb >> log/script.log 2>> log/script.log < /dev/null &'
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
I am very new to Linux and Bash scripting. Also my first question on stackoverflow.
I am trying to create a bash script which I want to use from any directory.
So far this is what I did
Created a simple bash file first
#!/usr/bin/bash
echo "This is a bash script"
exit 0
I set the permissions for execute using chmod +x myfilename.sh
And then I edited the .profile file under ~/.profile
Added the line "export PATH="$PATH:$HOME/bash_course/scripts"
After that I ran the command source ~/.profile
Now I tried to run myfilename from the terminal, but it returns Command not found.
Any idea what could have gone wrong?
I checked the path of my bash and it is /usr/bin/bash
If I run ./myfilename.sh from file path, it is working. But I am trying to run from other directories.
FYI : I am doing all of this on a WSL
Found the issue. My path was actually /bash-course/scripts and not /bash_course/scripts
I corrected the exported path under .profile
Thanks everyone
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
#!/usr/bin/env bash
#!/bin/bash
#!/bin/sh
filename='/home/supersaiyan/sample1.sh'
for i in 1 2 3 4 5
do
echo "String $i"
x1+="String"$i
done
echo "#Added string is: $x1" >> $filename
echo "The following string has been added to the file: $x1"
Here's the bash script I created which runs fine when using the bash command. It doesn't work in crontab though.
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
5 * * * * echo '#tanginamo cron tester' >> /home/supersaiyan/samplerz.sh
* * * * * /bin/bash /home/supersaiyan/sample1.sh
Here's what I put in crontab. The first line is just for testing and is working fine so I'm really lost on why the second one isn't working.
EDIT: Tried removing the SHELL and PATH lines to no avail
The .sh file is already modified as executable
Your output should be going to a different file than your actual script file.
You need to change :
filename='/home/supersaiyan/sample1.sh'
to:
filename='/home/supersaiyan/sample1.out'
...and run the script again.
You may want to review it's contents past line 10 or so.
Enjoy! :)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I would like store the terminal output to a file. I execute the command and cannot view the terminal output in the file but I am able to view the output in the terminal. Kindly help.
./bbmap.sh in=sequence.fasta covstats=constats.txt covhist=covhist.txt basecov=basecov.txt bincov=bincov.txt > output.txt
Validate the output of the script without redirecting to a file.
You can also pipe the output through tee so the output will be shown before sending it to a file.
script.sh |tee script_output.txt
Found the problem, add "command 2> file". T
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm using the commands pushd and popd in my .zshrc. I don't want these two commands to print anything to the console.
Therefore I tried to use it this way: pushd > /dev/null.
But now the output is: permission denied: /etc/null.
> /dev/null/ works for all other commands directly typed into my console (this tells me, that the permissions on /dev should be set correctly).
As Keith Thompson mentioned, I accidentally typed > /etc/null instead of > /dev/null
Fixing that typo solved my problem.
I should have better read the output:
permission denied: /etc/null
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to Linux commands. I have a requirement where I want to start Tomcat using a shell script. The location of startup.sh file is in /usr/lib/apache-tomcat-7.0.14/bin/. Tomcat is starting using command sh startup.sh. I want to create a shell script so that it will go to that folder and will execute sh startup.sh command. How can I do this using a shell script? Can anyone share the script for doing this?
Are you serious?
#!/bin/bash
cd /usr/lib/apache-tomcat-7.0.14/bin/
sh startup.sh
#!/bin/bash
exec /usr/lib/apache-tomcat-7.0.14/bin/startup.sh
is simpler (as does not have a shell kicking around)