Timeline for One-Liner needed: Stop httpd if running already & Start httpd if not running
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 15, 2015 at 16:57 | history | edited | Otheus | CC BY-SA 3.0 | Edited as suggested in a comment. |
| Apr 15, 2015 at 16:34 | comment | added | frank | very good point - I am with you but it would take me a day to play around to achieve what you mentioned in the previous comment. So for my current purpose the provided script is perfect enough (also in terms of its logic and simplicity). | |
| Apr 15, 2015 at 16:29 | comment | added | Otheus | The script doesn't cover some unusual boundary cases: (1) is-active is true but httpd is actually hung and non-responsive so that stop() doesn't succeed (2) systemctl fails to start httpd. Either way, the exit code will be non-zero but you may not see why in the logs. Solve this with something like || echo "Unknown failure: $?" between the final fi and the tee. It's also useful to date-time stamp the logs. Do this by preceding the whole thing with echo -n $(date "+%s %F %T"): | |
| Apr 15, 2015 at 16:23 | comment | added | frank | sweet! Thanks so much. I wonder why its so easy to understand if you see it written, but so hard figuring out how to achieve that without help. | |
| Apr 15, 2015 at 16:22 | vote | accept | frank | ||
| Apr 15, 2015 at 13:49 | history | answered | Otheus | CC BY-SA 3.0 |