]>
code.delx.au - monosys/blob - bin/find-services-to-restart
3 function get_pids_to_restart
{
5 awk '/DEL|(deleted)/ { print $2 }' | \
9 function find_service_for_pid
{
10 systemctl status
"$1" | \
11 awk '$2 ~ /\.service$/ && NR == 1 { print $2 }'
14 function is_cron_child
{
15 if [ "$1" != "cronie.service" ]; then
18 if systemctl show cronie
-p MainPID |
grep -q "$2"; then
24 function echo_kill_pid
{
25 echo "sudo kill $1 # $(ps -p"$1" -o user=,cmd=)"
28 function echo_restart_service
{
29 echo "sudo systemctl restart $1"
32 for pid
in $
(get_pids_to_restart
); do
33 if [ "$pid" = 1 ]; then
34 echo "sudo systemctl daemon-reexec"
38 service
="$(find_service_for_pid "$pid")"
39 if is_cron_child
"$service" "$pid"; then
42 elif [ -n "$service" ]; then
43 echo_restart_service
"$service"