klenwell information services : DevFabric

Wiki source for DevFabric


Show raw source

=====Fabric Development=====
return to DevPython

====Overview====
Python command-line for automating sysadmin tasks.

====Topics====
FabricEditRemoteFile
FabricKillProcess

====Boilerplate====
===Set user/host dynamically and ignore errors===
%%(python)
with settings(user=user, host_string=host, warn_only=True):
run(some_command)
%%

===Kill Remote Process===
%%(python)
def kill_remote_process(keyword):
"""kill process; ref: http://stackoverflow.com/a/3510850/1093087"""
cmd_f = """kill -9 $(ps aux | grep '%s' | grep -v grep | awk '{print $2}')"""
cmd = cmd_f % (keyword)
run(cmd)
%%

====References====
http://docs.fabfile.org