I am wanting to background a long running script, which I know I can do using the following:  nohup ./install.sh &amp;&gt;/dev/null &amp;   However, I also realize that if I leave that session, I can no longer see it running using job, since it would be running on another session if I login and then log back in.  My question is, before I run a script in the background, is there a way I can set it up so that I can return/foreground that script later? Even after I have logged out and then back in?
54788
I'm doing some test-runs of long-running data migration scripts, over SSH. Let's say I start running a script around 4 PM; now, 6 PM rolls around, and I'm cursing myself for not doing this all in screen.  Is there any way to "retroactively" nohup a process, or do I need to leave my computer online all night? If it's not possible to attach screen to/nohup a process I've already started, then why? Something to do with how parent/child proceses interact? (I won't accept a "no" answer that doesn't at least address the question of 'why' -- sorry ;) )
87006
I have a setup where my users log on using ldap and it works just fine.  I want to run a script after my users login (its a script that will detect which groups they are in and map network shares accordingly), and after they logout (umounting their shares).  Both scripts are done and they work.  I want that when the user logs in the box a script runs downloading the mounting script from my server (wget i guess?) and runs it, same thing for logout.  Can it be done? I've been searching the net and had no luck so far. I've managed to make that work on shell login/logout, but my users dont even know what shell is and have no use for it :)
50241
I'm trying to spawn an SSH from my bash profile script that runs in the background for connection sharing (via its control socket). The problem I'm running into is a reliable way to ensure the SSH doesn't stay running once the TTY is closed (or more directly; once the parent bash shell has exited).    I know the shell can run commands (to terminate SSH) when it exits gracefully, but I'm trying to handle all possible scenarios where the shell doesn't get a chance to shut things down.  Is there a clever way I can do this?  The best idea I've had is   ssh -o PermitLocalCommand=yes -o LocalCommand='cat &gt;/dev/null; kill $PPID' $HOST &amp;   But this won't work because I need the command to only background once it has successfully started. Alternatively, I can't use -fN instead of the shell's &amp; because the SSH -f only backgrounds after the LocalCommand has completed.  Also I'm trying to avoid running any command on the remote host. Otherwise I could probably do something like ssh -fN $HOST 'cat &gt;/dev/null'
13012
I have a few cleanup commands to run for my datacaching scheme.  I was thinking a bash script would be an easy way to check if the full clean up job needed to be run.  But the cache is very time sensitive, so the check script needs to run every second.  What's the best way to do this?  Crontab only goes down to minutes, which makes sense for most applications.  Can I install a bash script as a background service?  On second though, can I just start it with the &amp; command and make it loop forever with a one second sleep?
115615
I want to execute a script, start.sh on a remote server which runs this:  nohup node server.js &amp;   Naively, I call SSH like this:  ssh myserver &lt;&lt;EOF ./start.sh &amp; EOF   This starts the script, but leaves the session connected. I want to follow this step with other commands in a script, so that's no good.  How can I SSH to the remote machine, launch a nohup command into the background, then disconnect? I suppose I could put the SSH process itself into the background, but that doesn't seem right.
35519
Is there any way to make/run a bash script on reboot (like in Debian/Ubuntu for instance, since thats what my 2 boxes at home have)  Also, any recommended guides for doing cron jobs? I'm completely new to them (but they will be of great use)
42569
Which methods exist to keep a command that was started from shell on running after logging out from from shell?
95920
Let's say I have a bash script with the following:  #!/bin/sh gedit rm *.temp   When I execute it using sh ./test.sh, gedit pops-up but the rm part does not run until after I close gedit.  I want the script to continue running even if gedit isn't closed; like the gedit isn't blocking the bash execution.  The example I gave is just an example (putting the rm first won't work in a real situation).
7505
I am using putty to interact with Linux server. I have started a process using putty. The process is running and will take 5-6 hours. I want that process to keep running after I close the putty session. How can I keep that process alive after closing the putty session? I do not want to keep the computer ON all the time. Is there any way to do this?.
46129
I really like the look of the output of   But that script is only used for Input/Output operations.  How can I use it as a replacement for sleep but with visual feedback?  sleep 10
91395
I have an .sh script. I would like to wait 25 minutes and then continue running, NOT repeat. It's something like this:  #!/bin/bash /bin/bash ~/path/script.sh   I want it to kill a process after waiting 25 minutes.  #Wait 25 minutes killall process
31487
I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run.  For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate place to do these?  What's the difference between putting things in .bashrc, .bash_profile, and .environment?  I've also seen other files such as .login, .bash_login, and .profile; are these ever relevant?  What are the differences in which ones get run when logging in physically, logging in remotely via ssh, and opening a new terminal window?  Are there any significant differences across platforms (including Mac OS X (and its Terminal.app) and Cygwin Bash)?
36970
I have some applications that need to run on my laptop all the time.   I use a bash script to start these applications. In my script I have a loop that looks similar to this:    while true; do     xterm done   This runs an application (xterm in this case) and if the application crashes, the loop starts it again.    This has a disadvantage that there is no "clean" exit from this loop. So even if the intention of the user is to close xterm, the loop starts it again.    Is there a way to start an application from bash script, watch whether it is running, to re-run it if script crashed or do nothing if the user closed it properly ?
2844
I'm working on a Linux machine through SSH (Putty). I need to leave a process running during the night, so I thought I could do that by starting the process in background (with an ampersand at the end of the command) and redirecting stdout to a file.  To my surprise, that doesn't work. As soon as I close the Putty window, the process is stopped.  How can I prevent that from happening??
10868
If script.sh is just something typical like  #!/bin/bash echo "Hello World!"   Is there a preferred way to run the script? I think you first have to chmod it so it becomes executable?
111762
I have seen wrapper script examples which in a nutshell are following:  #!/bin/bash  myprog=sleep echo "This is the wrapper script, it will exec "$myprog""  exec "$myprog" "$@"   As seen above, they use exec to replace the newly created shell almost immediately with the $myprog. One could achieve the same without exec:  #!/bin/bash  myprog=sleep echo "This is the wrapper script, it will exec "$myprog""  "$myprog" "$@"   In this last example, a new bash instance is started and then $myprog is started as a child process of the bash instance.  What are the benefits of the first approach?
6219
I'd like to run a .sh file using bash on logout and shutdown of Ubuntu. I have searched up and down the web and have found only fixes for KDE and GNOME. The script is simple, I just need to know if I can add the line of code to the "logoff/shutdown" file or if I need to reference it in another script.