> some questions
> a.) why 'status' after 'start' ?
> the output of that command wont go anywhere where you could see it
> b.) will 'start' fail if already started ?
> will 'stop' fail if not started ?
>
> we dont want to raise exception in the event of either of 'b' erroring out if
> the end result is correct.
Given 'a' and 'b' I'll remove status; I thought we wanted to error if it failed to start for whatever reason and status returns '3' if the service is stopped;
wrt 'b' specifically, it's idempotent
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: active (running) since Tue 2014-12-02 16:32:39 UTC; 34s ago
Main PID: 759 (sshd)
CGroup: /system.slice/ssh.service
└─759 /usr/sbin/sshd -D
Dec 02 16:32:39 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:32:39 localhost.localdomain sshd[759]: Could not load host key: /e...y
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on 0.0.0.0....
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on :: port 22.
Dec 02 16:32:44 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:08 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: inactive (dead) since Tue 2014-12-02 16:33:17 UTC; 2s ago
Process: 759 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=0/SUCCESS)
Main PID: 759 (code=exited, status=0/SUCCESS)
Dec 02 16:32:39 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:32:39 localhost.localdomain sshd[759]: Could not load host key: /e...y
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on 0.0.0.0....
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on :: port 22.
Dec 02 16:32:44 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:08 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:17 localhost.localdomain systemd[1]: Stopping OpenBSD Secure She...
Dec 02 16:33:17 localhost.localdomain systemd[1]: Stopped OpenBSD Secure Shel...
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ echo $?
3
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ echo $?
0
> some questions
> a.) why 'status' after 'start' ?
> the output of that command wont go anywhere where you could see it
> b.) will 'start' fail if already started ?
> will 'stop' fail if not started ?
>
> we dont want to raise exception in the event of either of 'b' erroring out if
> the end result is correct.
Given 'a' and 'b' I'll remove status; I thought we wanted to error if it failed to start for whatever reason and status returns '3' if the service is stopped;
wrt 'b' specifically, it's idempotent
ubuntu@localhost:~$ sudo systemctl start ssh system/ ssh.service; enabled) slice/ssh. service
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/
Active: active (running) since Tue 2014-12-02 16:32:39 UTC; 34s ago
Main PID: 759 (sshd)
CGroup: /system.
└─759 /usr/sbin/sshd -D
Dec 02 16:32:39 localhost. localdomain systemd[1]: Started OpenBSD Secure Shel... localdomain sshd[759]: Could not load host key: /e...y localdomain sshd[759]: Server listening on 0.0.0.0.... localdomain sshd[759]: Server listening on :: port 22. localdomain systemd[1]: Started OpenBSD Secure Shel... localdomain systemd[1]: Started OpenBSD Secure Shel... system/ ssh.service; enabled) /usr/sbin/ sshd -D $SSHD_OPTS (code=exited, status=0/SUCCESS)
Dec 02 16:32:39 localhost.
Dec 02 16:32:39 localhost.
Dec 02 16:32:39 localhost.
Dec 02 16:32:44 localhost.
Dec 02 16:33:08 localhost.
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/
Active: inactive (dead) since Tue 2014-12-02 16:33:17 UTC; 2s ago
Process: 759 ExecStart=
Main PID: 759 (code=exited, status=0/SUCCESS)
Dec 02 16:32:39 localhost. localdomain systemd[1]: Started OpenBSD Secure Shel... localdomain sshd[759]: Could not load host key: /e...y localdomain sshd[759]: Server listening on 0.0.0.0.... localdomain sshd[759]: Server listening on :: port 22. localdomain systemd[1]: Started OpenBSD Secure Shel... localdomain systemd[1]: Started OpenBSD Secure Shel... localdomain systemd[1]: Stopping OpenBSD Secure She... localdomain systemd[1]: Stopped OpenBSD Secure Shel...
Dec 02 16:32:39 localhost.
Dec 02 16:32:39 localhost.
Dec 02 16:32:39 localhost.
Dec 02 16:32:44 localhost.
Dec 02 16:33:08 localhost.
Dec 02 16:33:17 localhost.
Dec 02 16:33:17 localhost.
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ echo $?
3
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ echo $?
0