]> code.delx.au - monosys/blobdiff - find-services-to-restart
smart-stats: smartctl returns non-zero if there are errors in the smart log
[monosys] / find-services-to-restart
index d4fb2bee29d009407c2ff69009b463f4042c65ec..ce497f8a71ac949bcc525254d99698d8e4b5e25c 100755 (executable)
@@ -2,16 +2,13 @@
 
 function get_pids_to_restart {
     sudo lsof +c 0 / | \
-        grep 'DEL\|(deleted)' | \
-        awk '{print $2}' | \
+        awk '/DEL|(deleted)/ { print $2 }' | \
         sort -u
 }
 
 function find_service_for_pid {
     systemctl status "$1" | \
-        head -n1 | \
-        awk '{print $2}' | \
-        grep '\.service$'
+        awk '$2 ~ /\.service$/ && NR == 1 { print $2 }'
 }
 
 function is_cron_child {