How to execute nohup command with VLC in Linux - linux

I cant seem to get this to work. If I execute the command like I always do then VLC closes.
here is the command
./vlc -vvv http://192.168.1.xx:6002 --sout '#transcode{venc=x264{preset=ultrafast},vcodec=h264,vb=1300,ab=128}:standard{access=http,mux=ts,dst=192.168.1.50:9002}'
and here is the nohup command
nohup ./vlc -vvv http://192.168.1.xx:6002 --sout '#transcode{venc=x264{preset=ultrafast},vcodec=h264,vb=1300,ab=128}:standard{access=http,mux=ts,dst=192.168.1.50:9002}' 2>&1 &;
This does not work. Am I doing something incorrectly?
Basically i want to execute the command and be to execute another commands as regular command produces continuous output

There is a semicolon at the end of the second command, this will cause it to fail (as I found out earlier today). A semicolon is invalid following an & in bash, if you want another command on the the same line (usual reason for a semicolon), you just put a space after the & and add the other command.
That said nohup is not the way to stop vlc from producing 'continuous output'. For that you would do &>/dev/null instead of 2>&1.

Tip: use cvlc
nohup ./cvlc -vvv 192.168.1.50:9981/playlist/channelid/1 --sout '#transcode{vcodec=h264,vb=1900,ab=128}:standard{access=http,mux=ts,dst=192.168.1.50:9002}' &
This worked for me

Related

Execute a command in a new terminal window

I'm on ubuntu 17.04, and I'm trying to execute some commands in sequence, so I have written this shell script:
#!
sudo java -jar ~/Desktop/PlugtestServer.jar
sudo /opt/lampp/lampp start
sudo node httpServer.js
The problem is that after the first command, it execute PlugtestServer and then stop on it, because it is a server and continue to execute it. There is a command in order to automatically open a new terminal and execute PlutestServer in it?
There is way to open a new terminal window and execute command in it using gnome-terminal
The sample format for command is:
gnome-terminal -e "command you want to execute"
gnome-terminal -e "./your-script.sh arg1 arg2"
Hope that helps!!
Your script stays on the first command showing output, you can make the shell move on by adding "&" to the end of your lines. However this might still not do what you want, if you want PlugTestServer to remain running when you log out. For that you should include "nohup" which will keep the command running while piping output to a file.
So, an example:
#!/bin/sh
nohup java -jar ~/Desktop/PlugtestServer.jar > plugtest.out & #Pipes output to plugtest.out, use /dev/null if you don't care about output.
/opt/lampp/lampp start
node httpServer.js
Notice I removed sudo from the script. It's generally better to invoke the script with "sudo" unless you have specific reason to, at the very least it simplifies the commands.
I'm not sure if your second and third command "fork" or "block", so add "nohup" and "&" if you need to.

Start detached screen with ssh , without killing after the commands execute [duplicate]

I'm lazy, and I prefer that computers do my work for me. I ssh into several machines on a daily basis, so I created a simple script that launches some xterm windows and places them in positions I want (as you can see, I'm using bash):
#!/bin/bash
xterm -geometry 80x27+1930+0 &
xterm -geometry 80x27+2753+0 &
xterm -geometry 80x27+1930+626 &
xterm -geometry 80x27+2753+626 &
However, the next thing I do is go to the first window and type in
ssh server_a
then in the second
ssh server_b
and so on. What I'd like to do is have my script do the ssh commands in each xterm window, and then leave the windows open for me to do my work. I've seen the -e option for xterm, but the window closes after I execute my command. Is there a way to do this?
I apologize if this is a duplicate question. I've searched around and haven't had any luck with this. Many thanks!
I'd love to see a more elegant answer, but what I came up with does work:
xterm -e bash -c 'echo foo; exec bash'
Replace echo foo with the command of your choice, and you're good to go.
This answer gives one of the best answers I've seen so far to do this. Use the bash --init-file flag either in the shebang or when executing the terminal:
#!/bin/bash --init-file
commands to run
... and execute it as:
xterm -e /path/to/script
# or
gnome-terminal -e /path/to/script
# or
the-terminal -e bash --init-file /path/to/script/with/no/shebang
My only real complaint with the exec option is if the command executed prior to exec bash is long running and the user interrupts it (^C), it doesn't run the shell. With the --init-file option the shell continues running.
Another option is cmdtool from the OpenWin project:
/usr/openwin/bin/cmdtool -I 'commands; here'
# or
/usr/openwin/bin/cmdtool -I 'commands; here' /bin/bash
... where cmdtool injects the commands passed with -I to the slave process as though it was typed by the user. This has the effect of leaving the executed commands in the shell history.
Another option is to use gnome terminator. This creates and positions terminals interactively, and you can set up each terminal to run commands within terminator preferences.
Also does lots of extra tricks using keybindings for things like move, rotate, maximise/minimise of terminals within the containing terminator window
See: https://superuser.com/a/610048
"ClusterSSH controls a number of xterm windows via a single graphical console window to allow commands to be interactively run on multiple servers over an ssh connection"
https://github.com/duncs/clusterssh/wiki
$ cssh server_a server_b
$ command

How can I run a Linux command that still runs after I close my PuTTY SSH session?

I am connecting to my NAS over putty which is running linux on it.
I wanted to move a big directory from one location to another. Is it possible to keep the process running after I close the putty session ?
I am afraid that if I close putty the files will not be copied to the end ?
Start your task with 'nohup' and put it in the background with '&', e.g.:
$ nohup mv /here /there &
$ exit
and it should continue running.
I would suggest using screen for this.
Start a new screen,
screen -S <name of your screen>
and then you can perform your commands there, detach from the screen and re-attach to it at any time.
Detach by hitting the sequence
ctrl a d
and re-attach by typing
screen -r (or list the screens with screen -l).
Also have a look at Gnu screen survival guide.
You can run it as a background process as follows:
nohup mv source target &
However, you will not be able to interact with the process.
EDIT: nohup is also required to keep it running after the shell exits.
Using nohup would be best solution.
The following command in your terminal may help you out to run the script using nohup and redirect the output in your desired file.
General Syntax
nohup some_command &> nohup_log_file_name.out &
Example
nohup python script.py &> nohup_log_script.out &
So, if you use the above command, you will be able to find the outputs of the command in a log file named nohup_log_script.out

Having to hit enter with nohup

I have a shell command like this
sudo nohup coffee -c -w *.coffee &
disown $!
wait
but when I run the shell scrit it says nohup: appending output to 'nohup.out' and makes me hit enter.
How do I get around having to hit enter?
8 year old thread, but I found that none of these answers really solve the issue in the question.
The message nohup: ignoring input and appending output to 'nohup.out' is piped through stderr (AFAIK), so in order to silence that message, all you have to do is to redirect stderr to /dev/null, like so:
nohup mycommand 2> /dev/null
However, if you additionally want to run this process in the background with &, you will find that (for bash at least), there will be a single line output of the job number and PID (e.g. [1] 27184). To avoid this, run the entire command in a subshell, like so:
(nohup my command 2> /dev/null &)
But if you're using this in a script, the former solution is sufficient.
As far as I understand, you don't have to. The message is output to the console, but not added to your input buffer. Therefore you can just continue typing your commands in as if there were no message from nohup, the message will not interfere with your input.
Well, having to type not from the exact prompt position may be aesthetically not so pleasing.
You could also redirect the log manually:
sudo nohup coffee -c -w *.coffee > /tmp/coffee.log &
That way the message won't show up at all.
Ubuntu Linux 20.04: None of the answers above solved the problem for me: script blocks in any case, waiting for input
My Solution
[sudo] nohup `command` > nohub.log < enter.txt &
where enter.txt is a text file containing a single line separator.

How do I start a command from terminal so that terminal is not the parent?

Let's take example of a command "example-command".
I open terminal
I write example-command in terminal, and example-command executes.
Now if I close terminal, example-command gets killed too.
I now try with "example-command &", but the same behaviour.
How do I execute a command so that when I close the terminal, the command doesn't get terminated?
There are two ways, identical in result.
Use nohup when you start your program. E.g., nohup example-command. You can background and work with it normally; it will simply continue running after you've quit.
Alternatively, as #alamar noted, if you use bash as your shell, you can us the disown command. Unfortunately, as far as I know, disown is bash-specific; if you use another shell, such tcsh, you may be restricted to the nohup form above.
Please search for similar questions first.
Besides the ways listed above, you can do:
setsid command_name
For example:
setsid xclock
Thanks
In Zsh (not bash) you can:
example-command &; disown {pid}
or just
example-command &; disown
You could also consider using the screen command.
nohup example-command
You can also use the 'at' or 'batch' commands and give it the current time.
disown is a bash builtin. You could create a wrapper shellscript for your command such as
#!/bin/bash
$1 &
P=`which $1`
disown `pidof ${P}`
Not the most robust script (by any means) but may help get you going. For example:
$./launch_script.sh myProgram
You can also do this in the source of the program if you are editing it.
Run: example-command
Press: Control-Z
Run: bg

Resources