View Single Post
Old 07-07-2016, 01:30 AM   #6
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You should take a live look at the processes using (h)top.

...

Code:
ps aux|grep "something"
will often discover the grep process itself, depending on the timing.
If you are looking for a list of only the matching processes, then traditionally you use
Code:
ps aux|grep "[s]omething"
since the regex doesn't match itself.

But I'd just check the return code of
Code:
pgrep -f calibre > /dev/null
rather than testing the integer value of three different commands in a pipe, ending with "wc".

Yes, the "if" builtin doesn't perform comparisons, it checks the return value of the "[" binary (alias for "test"). Make use of that fact to cut down on the rube goldberg code.

...

And as chaley said, you really should stick with software which is actually designed to restart unexpectedly-killed daemons. Monit is a great choice for that, but any decent init system should be able to handle that to some degree.

Last edited by eschwartz; 07-07-2016 at 01:38 AM.
eschwartz is offline   Reply With Quote