How do we execute a command such as it executes everytime one logs out or shutdowns or restarts the machine ?  To be more specific, I want the autotrash to be executed at logout, or shutdown or restart.
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.
109608
I have a shutdown hook in my application (created using Runtime.getRuntime().addShutdownHook). However if I launch the application from within Eclipse, when it is shut-down the shutdown hook doesn't execute.   I think this is because Eclipse sends the equivalent of a force-kill signal to the process, which doesn't cause the shut-down hook to execute (equivalent of taskkill /F on Windows or kill -p on Linux), though I'm not absolutely sure.  Does anyone know how to get around this? I'm running Windows (Vista), and I've a feeling it may be a Windows-specific issue, but I'm not sure.
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 :)
57593
I want to achieve some use cases in which:  I want to perform some tasks that require manual intervention before kicking in automation execution. For instance, I need to manually launch the browser, navigate to the desired page, perform some manual tasks like entering captcha manually and then run the automation script to continue from there.  Debugging – Let's say we are working on a test script for a certain page (product checkout) in the application. But the script to reach that page (add to cart) is not ready yet. We can manually launch the browser and navigate to that page and then run the automation script.  Can someone help me to achieve this type of scenario?
53495
How can I pause an rsync that's running?   First time I did Ctrl+C to kill it and used the -P flag to run again. Is this prone to corrupt the current file transfer?  Second time I simply put MacOS to sleep (by closing the lid). Looking at the running process I can see 2 (not sure why) with a status of 'S'.  Tried using   kill -SIGCONT   to resume the process, but it has no effect.
5205
My problem is that in Windows, there are command line windows that close immediately after execution. To solve this, I want the default behavior to be that the window is kept open. Normally, this behavior can be avoided with three methods that come to my mind:   Putting a pause line after batch programs to prompt the user to press a key before exiting Running these batch files or other command line manipulating tools (even service starting, restarting, etc. with net start xy or anything similar) within cmd.exe(Start - Run - cmd.exe) Running these programs with cmd /k like this:  cmd /k myprogram.bat   But there are some other cases in which the user:   Runs the program the first time and doesn't know that the given program will run in Command Prompt (Windows Command Processor) e.g. when running a shortcut from Start menu (or from somewhere else), OR Finds it a little bit uncomfortable to run cmd.exe all the time and doesn't have the time/opportunity to rewrite the code of these commands everywhere to put a pause after them or avoid exiting explicitly.   I've read  about changing default behavior of cmd.exe when opening it explicitly, with creating an  and manipulating its content in these locations:  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor\AutoRun   (The AutoRun items are _String values_...)  I put cmd /d /k as a value of it to give it a try, but this didn't change the behaviour of the stuffs mentioned above at all... It just changed the behaviour of the command line window when opening it explicitly (Start-Run-cmd.exe).   So how does it work? Can you give me any ideas to solve this problem?
46659
I am a new user, who has just been told to run / execute a command. The answer has some text with a grey background like this text here or  sometimes this text here.   However, I don't know what "run" or "command" means in relation to Ubuntu.  How do I do this?    This is intended for use as a Q&amp;A you can link to when you tell someone to run a command.
109800
Is it possible to have a program starting automatically when I connect to a specific router, and having it stop when I disconnect from this router?  Basically I want a program to run while I'm at work (flexible hours, so I can't just have some sort of timer function) but not when I'm at home - or somewhere else.  I'm running: Macbook air OS X Version 10.9.4
118230
I am trying to hibernate my computer from the command. I was using shutdown /s /t 20 to shutdown the the computer. I change /s to /h to hibernate and now it just returns the usage text as if it doesn't recognise what I have entered. In this is does say  /h         Hibernate the local computer.   Is there something else that I need to use with /h to get it to hibernate?
37135
Is there a way for a Java GUI application to respond to system shutdown or logoff events, other than to use JNI?  (On Windows, the JNI would use WM_QUERYENDSESSION, on Linux?)  The method should allow the program to prompt users to save, etc., and then continue the logoff process.
68571
I am using Putty to connect to a remote server. What I want to know is if there is any way to write my commands and allow them to keep running after I close the session with Putty. The reason for this is that I do not want to keep the computer ON all the time. Is there any way to do this?.  Update with the solution  For my question as it is presented the best solution is use one of the commands provided such as nohup, because you do not have to install any additional software. But if you are in the same problem use screen, install it and use it. It is amazing.  I have selected the answer of Norman Ramsey as favourite because propose several solutions using commands and screen. But please check the other answers specially the one of PEZ, then you get an insight of what screen is able todo.
52681
I was trying to shutdown my PC through SSH. I executed  sudo shutdown now  The user was logged-out and Ubuntu starting turning off, but it froze at the last screen with the Ubuntu logo and the loading dots. Any idea where the problem might be?  Also, what's the difference between shutdown and halt? What other similar commands are there?
87946
I'm connecting to a Linux machine through SSH, and I'm trying to run a heavy bash script that makes filesystem operations. It's expected to keep running for hours, but I cannot leave the SSH session open because of internet connections issues I have.  I doubt that running the script with the background operator, the ampersand (&amp;), will do the trick, because I tried it and later found that process was not completed. How can I logout and keep the process running?
10701
I am looking for a way to execute some console commands automatically when a command-prompt is opened in Windows, specifically to set some command aliases.  For example, when a command-prompt is opened, I want a command such as the following to be automatically run so that I can use ls instead of dir.  doskey ls=dir   How can this be done?
75804
How do I create a system-wide autostart file?  This would be on a cloud server running the desktop version of Maverick.  I logged in as root and created an autostart file using System/Preferences/StartupApplications but it ended up in /root/.config/autostart and did not execute (as far as I can tell) upon rebooting.  The autostart file is to invoke a bash script that invokes the VNC server.    I copied the .desktop autostart file from /root/.config/autostart to /etc/xdg/autostart and rebooted.  This did not seem to make a difference.  Edit As mentioned in a comment, the objective is to run my bash script which starts the VNC server upon boot; not upon a login.
11663
I am looking for a way to clean up the mess when my top-level script exits.  Especially if I want to use set -e, I wish the background process would die when the script exits.
85797
How can one configure MacOS (10.8 or higher) to automatically and immediately call a user-designated script (probably a bash script) upon the user closing the display lid of a MacBook Air or Pro?  Details.  I want to do this because in some scenarios my MacBook Air 2013 running 10.8.5 does not immediately sleep/lock the screen upon lid close (possibly because a VPN client is trying to open a connection).  As such, I want the system to immediately execute a script which calls  upon lid close.  However, I don't know how to call scripts upon display-lid closing.