I have made a shell script to run a server for a game I like. I need the server to run when I close putty. Right now putty is the console, but I need it to not close when I close the program down.  startServer.sh:     ~/server_1/srcds_run -game garrysmod +maxplayers 32 +map gm_bigcity I need it to run everything in there daemonized.
4738
I sometimes have long running processes that I want to kick off before going home, so I create a SSH session to the server to start the process, but then I want to close my laptop and go home and later, after dinner, I want to check on the process that I started before leaving work. How can I do that with SSH? My understanding is that if you break your SSH connection you will also break your login session on the server, therefore killing the long running process.
77842
As of Ubuntu 12.04, what is the proper/clean way to make the system execute a script upon boot? (not upon user login) e.g. running a daemon.
16261
How do I run a program in the background of a shell, with the ability to close the shell while leaving the program running? Lets say my UI is having problems or for some reason, I need to boot up a program from the terminal window, say, nm-applet:  nm-applet   When it's started, it occupies the foreground of the terminal window.  Is there any simple way to run the program in the background without needing to leave the terminal open or have it occupy the whole terminal?  On that note, I did find a way to run programs from the terminal and have it allow for other inputs, by appending an ampersand (&amp;) to the command as such:  nm-applet &amp;   But this isn't much use as any processes started in the terminal are killed once the terminal is closed.
97730
I have a shell script that executes a number of commands. How do I make the shell script exit if any of the commands exit with a non-zero exit code?
68175
I setup a LAMP server on my desktop Ubuntu install for testing web applications. How do I set it to only run when I tell it to rather than at startup? It is not used as a production web server but instead for testing PHP scripts I write before pushing them to my public web server.
69375
Whenever I login to my Linux server I'd like to have several commands run automatically (set some variables, change location, etc.)  This needs to be done on user login, not on system start.  How can I set it to do this?
99640
I'm running a private game server on a headless linux box. Because I'm not an idiot, said server is running as its own unprivileged user with the bare minimum access rights it needs to download updates and modify the world database.  I also created a systemd unit file to properly start, stop and restart the server when needed (for said updates, for example).   However, in order to actually call systemctl or service &lt;game&gt; start/stop/restart I still need to log in as either root or a sudo capable user.   Is there a way to tell systemd that for the &lt;game&gt; service, unprivileged user gamesrv is permitted to run the start/stop/restart commands?
8963
Related question:   Answer from there helped me a lot, this command does what I need:  ssh -R 2225:localhost:22 loginOfServerWithPublicIP@publicIP   So I wrote the script to reconnect all the time:   #!/bin/bash   while true; do     echo "try to connect..."     ssh -o ServerAliveInterval=240 -R 2225:localhost:22 user@host     echo "restarting in 5 seconds.."     sleep 5  done   And added it to the /etc/crontab. But I found out that works if only I execute it "by hand" from shell, but if it is called by cron, ssh connects and immediately finishes. (so, the script above reconnects all the time)  From man ssh, I found that for background connections I should call it with -n key, but it didn't help. Then, I just looked around for similar scripts and I found that it works if I call tail -f something, i.e. some "neverending" command, so I just created empty file /tmp/dummy_file and now my ssh command looks like this:  ssh -o ServerAliveInterval=240 -R 2225:localhost:22 -n user@host tail -f /tmp/dummy_file   It works now! But, this solution seems a bit ugly, plus I don't really understand actual reasons of that behavior. Just by chance, I tried to call bash instead of tail -f (bash seems to me "neverending" command, too), but it doesn't work.  So, could anyone please explain this behavior, and what is the correct way to create background ssh connection to keep reverse ssh tunnel up?
56386
Each time putty is closing the session after some time if it is idle.  There is no time parameter on putty, so how can I keep my putty ssh session always Alive?
15366
I have a running program on a SSH shell. I want to pause it and be able to unpause its execution when I come back.  One way I thought of doing that was to transfer its ownership to a screen shell, thus keeping it running in there.  Is there a different way to proceed?
18512
I have a script that works well when I ssh to the server to execute it myself, but has problems when , a continuous integration server, runs it.  I am automating tests on an embedded linux system (the target). The target is connected to Server A (RHEL 5) via serial and operated over minicom. Server B (FC 12) builds the tests that actually run on the target, and can ssh to Server A. Server C (RH) hosts Hudson, with Server B as a slave.   I've written a runscript (http://linux.die.net/man/1/runscript) script to do everything needed on the actual target; it boots the image, mounts a directory from Server B and executes the tests. A bash script on Server B invokes minicom with the runscript script along with some companion actions. I have a bash script on Server B which uses   ssh -t -t ServerA bashScript.sh   to get those tests run on the target. I am on Server C, I can get those tests run by ssh'ing to Server B and executing the script that ssh's to Server A which executes minicom with runscript. Whew.  To review:  Server A: Hudson uses its slave mechanism to ssh to Server B.  Server B: kickOffTests.sh has the line ssh -t -t ServerA runTests.sh  Server A: runTests.sh calls a perl script which invokes minicom -S my.script ttyE1  Target, after booting: Mounts a directory from Server B, where the tests are, and enters that directory. It invokes yet another bash script, which runs the tests, which are compiled C executables.  Now, when I execute any of these scripts myself, they do what they should. However, when Hudson tries to do the same thing, over in the minicom session it complains about a line in the "yet another bash script" that invokes the C executable, ./executable, with ./executable: cannot execute binary file  I still have a lot to learn about linux, but I surmise this problem is a result of Hudson not connecting with a console. I don't know exactly what Hudson does to control its slave. I tried using the line export TERM=console in the configuration just before running kickOffTests.sh, but the problem remains.  Can anyone explain to me what is happening and how I can fix it? I cannot remove any of the servers from this equation. It may be possible to take minicom out of the equation but that would add an unknown amount of time to this project, so I'd much prefer a solution that uses what I already have.
10006
I have a shell script. I want to configure my script to run automatically during startup. I know how to do this from GUI. But I wanted to do this from terminal. How can I do this?  On a primary research I found that the file needs to be moved to /etc/int.d/ directory. But this operation needs sudo permission. I wanted to do this without super user permissions.   I also found that there are files under ~/.config/autostart/ which are having some settings regarding the startup applications. But I don't know how to edit them to achieve this.   Can someone tell me the exact procedure to achieve this?
25100
In my Ubuntu, i run java application in background. I use bash script to run it and now it looks like:  nohup java -jar app.jar &amp; exit 0   The problem that i want to be able to write an input string to my application, without making it foreground, from different terminals/sessions. Something like  echo "mytext" &gt; /appdir/in   How should i change my script?
103180
I have a server log that outputs a specific line of text into its log file when the server is up. I want to execute a command once the server is up, and hence do something like the following:  tail -f /path/to/serverLog | grep "server is up" ...(now, e.g., wget on server)?   What is the best way to do this?
26709
After I create a bash script and double click it in Nautilus I am prompted with this - Do you want to run "sleepytime", or display its contents? With Run in terminal, Dislpay, Cancel and Run as options.    Is it possible to just choose "run" or "run in terminal" by default?
27430
I have some conditions for some background job to run:  condition-command &amp;&amp; condition-command &amp;&amp; background-job &amp;   The problem is: I want the conditions to block until the job runs, as if I had run:  condition-command; condition-command; background-job &amp;   But it isn't a condition, if previous command fails I do not want the job to run.  I realised it is asynchronous, but it should not, in my mind the both following scripts should be the same, but they do not:  sleep 2; echo foo &amp; sleep 1; echo bar; wait   # prints foo, then bar: correct sleep 2 &amp;&amp; echo foo &amp; sleep 1; echo bar; wait # prints bar, then foo: bug   I know if I test $? variable it would work, or if I put the last one inside a subshell (but then I would lost job controls, I want to avoid daemons), but I want to know why bash make it this way, where is it documented? Is there any way to prevent this behaviour?  Edit: Chained ifs is disgusting, that is why I will not accept it as a alternative way. Edit 2: I know a subshell is possible, but it will not work for me, let us imagine I want to run a bunch of commands then wait in the end. It will be possible if i check the existence of /proc/$PID directory, but it would be a pain in the neck if there are several jobs. Edit 3: The main question is WHY bash does it, where is it documented? Whether or not it has a solution is a bonus!
14143
I have to run a local shell script (windows/Linux) on a remote machine. I have SSH configured on both machine A and B. My script is on machine A which will run some of my code on a remote machine, machine B. The local and remote computers can be either Windows or Unix based system. Is there a way to run do this using plink/ssh?