Re: Remotely shutdown multiple PCs via script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Fri, Dec 9, 2011 at 2:02 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
On Fri, 9 Dec 2011, Frank Elsner wrote:

> > On Fri, 9 Dec 2011 14:16:00 -0500 (EST) Alan Stern wrote:
> > On Fri, 9 Dec 2011, Doug Kuvaas wrote:
> >
> > > Here is what I am trying to do:
> > >
> > > >From a central server running HP-UX, I would like to shutdown multiple
> > > Fedora PCs using a script.  This in itself is not a problem.  I have an
> > > account on the machines added to the sudoers file to allow them to shut
> > > down the systems, and connect to said systems using ssh.  I can get the
> > > systems to shut down remotely using the command ssh -t user@host "sudo
> > > /sbin/shutdown -h now".  If I run the script on the host computer it works
> > > like I would expect.
> > >
> > > The problem I am running into is the host computer is typically accessed
> > > through one of the Fedora PCs being used to shut it down.  So when I run
> > > the script, it gets to the point where it is telling the current computer
> > > to shutdown, the script is terminated and no further systems shut down.
> >
> > > Anyone have any ideas?
> >
> > When invoking the script from one of the PCs, run it in the background
> > (maybe with nohup) so that it doesn't get killed when the PC shuts
> > down.
>
> Whou! Programs started with nohup keep running after shutdown! Get real.

Yes, of course programs started with nohup don't keep on running after
shutdown.  That's not Doug's problem, however (although it may be a
little hard to tell because of a grammatical mistake in his original
post).

His problem is that programs running _on the server_ need to keep on
running after the _PC_ is shutdown.  That's exactly what nohup will do.

Alan Stern

--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org

I have actually tried ssh -t user@host "nohup /path/to/shutdownscript &" and it seemed to be doing the same thing....waiting for the shutdownscript to finish before moving to the next line.    I was expecting the nohup <command> & to immediately return back to the script and not wait for the command to complete. 

I seem to have it figured out now though.  I should have been using ssh -f instead of ssh -t for my script.  I also changed the nohup command so that it redirects all output to /dev/null.  That fixed the command not returning to the script issue that I was seeing.  

I also discovered that I forgot to turn of the RequireTTY default for sudoers, which was causing the script to work perfectly when I ran it locally on the machines, but when trying to call the scripts remotely made them appear to not run at all...they were running, the sudo command was just refusing to run without a controlling terminal.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux