Sunday, May 19, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 10590  / 2 Years ago, tue, june 7, 2022, 7:53:54

I am trying to build a script/command that will restart our Asterisk/Elastix service on our PBX. The script is basically using simple command with auto log-in public key that run from Ubuntu 14.04LTS:



The command script is:



ssh user@iphost 'service asterisk restart'


But after the command finished and service restarted, the ssh stays and only after ctrlc its breaks out.



My question, is how can I terminate the session after the command completes?


More From » command-line

 Answers
2

Try redirecting stdin, stdout, and stderr to /dev/null. For an explanation, see https://serverfault.com/questions/36419/using-ssh-to-remotely-start-a-process.


[#24102] Thursday, June 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wherejuic

Total Points: 53
Total Questions: 123
Total Answers: 117

Location: Zambia
Member since Mon, Jan 23, 2023
1 Year ago
wherejuic questions
Thu, Aug 19, 21, 18:07, 3 Years ago
Wed, May 12, 21, 03:23, 3 Years ago
Sat, Nov 13, 21, 05:27, 3 Years ago
Mon, Sep 5, 22, 17:36, 2 Years ago
;