James B. Byrne
2015-Sep-30 13:33 UTC
[CentOS] CentOS-6.7 Passing delayed shutdown via ssh command line argument?
If I log into a host via ssh from my workstation then I can enter this: shutdown -r +90& and log out. The shutdown command will continue in effect and will activae 90 minutes later. However, if I do this instead: ssh -t host.domain.tld 'shutdown -r +90&' then the shutdown command does not remain in effect. Why is this so and is there some way to achieve this? -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
Tony Mountifield
2015-Sep-30 14:02 UTC
[CentOS] CentOS-6.7 Passing delayed shutdown via ssh command line argument?
In article <f90407e5ac62949cab27d3bda74faa74.squirrel at webmail.harte-lyne.ca>, James B. Byrne <byrnejb at harte-lyne.ca> wrote:> If I log into a host via ssh from my workstation then I can enter this: > > shutdown -r +90& > > and log out. The shutdown command will continue in effect and will > activae 90 minutes later. > > However, if I do this instead: > > ssh -t host.domain.tld 'shutdown -r +90&' > > then the shutdown command does not remain in effect. Why is this so > and is there some way to achieve this?I think shutdown receives a HUP signal when the connection is terminated, because it still has the ssh tty as its controlling terminal. I've just done some experimenting using sleep instead of shutdown, and found this: - you need to omit the -t - you need to redirect stdin/stdout/stderr So try: ssh host.domain.tld 'shutdown -r +90 </dev/null >/dev/null 2>&1 &' Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
James B. Byrne
2015-Sep-30 14:03 UTC
[CentOS] {SOLVED] Re: CentOS-6.7 Passing delayed shutdown via ssh command line argument?
On Wed, September 30, 2015 09:33, James B. Byrne wrote:> If I log into a host via ssh from my workstation then I can enter > this: > > shutdown -r +90& > > and log out. The shutdown command will continue in effect and will > activae 90 minutes later. > > However, if I do this instead: > > ssh -t host.domain.tld 'shutdown -r +90&' > > then the shutdown command does not remain in effect. Why is this so > and is there some way to achieve this? > >Why is it that after beating my brains out and finally asking for help the answer appears? I have to close the stdxxx files before putting shutdown into the background. This seems to work: ssh host.domain.tld 'shutdown -r +90 > /var/log/shutdown_$(date +%Y%m%dT%H%M).log 2>&1 <&- &' -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3