Skip to content

Instantly share code, notes, and snippets.

@martinrusev
Created December 18, 2015 21:18
Show Gist options
  • Select an option

  • Save martinrusev/45a420e9e3d791610b05 to your computer and use it in GitHub Desktop.

Select an option

Save martinrusev/45a420e9e3d791610b05 to your computer and use it in GitHub Desktop.
# kill all of the user processes
ps -u amonagent | grep -v PID | awk '{print $1}' | xargs -i kill {}
sleep 2
ps -u amonagent | grep -v PID | awk '{print $1}' | xargs -i kill {}
# Systemd
if which systemctl > /dev/null 2>&1 ; then
systemctl stop amonagent
# Sysv
else
service amonagent stop
fi
# Systemd
if which systemctl > /dev/null 2>&1 ; then
systemctl disable amonagent
# Sysv
else
# update-rc.d sysv service:
if which update-rc.d > /dev/null 2>&1 ; then
update-rc.d -f amonagent remove
update-rc.d amonagent stop
# CentOS-style sysv:
else
chkconfig --del amonagent
fi
fi
getent passwd amonagent >/dev/null && userdel amonagent
getent group amonagent >/dev/null && groupdel amonagent
# Remove config
rm -rf /etc/opt/amonagent
# Remove binary
rm -rf /opt/amonagent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment