3

Can you recommend on a python tool / module that allows scheduling tasks on remote machine in a network?

Note that the solution must be able to not only run certain jobs/commands on remote machines, but also verify that jobs etc are still running (for example, consider the case where a machine dies after a task has been assigned to it?)

user3262424
  • 7,223
  • 16
  • 54
  • 84

3 Answers3

3

RPyC or Remote Python Call, is a transparent and symmetrical python library for remote procedure calls, clustering and distributed-computing. Here an example from Wikipedia:

import rpyc
conn = rpyc.classic.connect("hostname")  # assuming a classic server is running on 'hostname'

print conn.modules.sys.path
conn.modules.sys.path.append("lucy")
print conn.modules.sys.path[-1]

# a version of 'ls' that runs remotely
def remote_ls(path):
    ros = conn.modules.os
    for filename in ros.listdir(path):
        stats = ros.stat(ros.path.join(path, filename))
        print "%d\t%d\t%s" % (stats.st_size, stats.st_uid, filename)

remote_ls("/usr/bin")

# and exceptions...
try:
     f = conn.builtin.open("/non/existent/file/name")
except IOError:
     pass

To check if the remote server has died after assigning it a job, you can use the ping method of the Connection class. The complete API is described here.

Ralph
  • 5,154
  • 1
  • 21
  • 19
  • @Ralph: thank you. What happens if machine dies after a task has been assigned to it? will `RPyC` help in such a case? – user3262424 Apr 15 '11 at 01:52
  • you will need to code that part, have the task send a signal after it's done and check that – OneOfOne Apr 15 '11 at 02:16
  • @OneOfOne: so 'rPyC' is just a connector to the remote machine that invokes the job on it? what's the difference between this and programatically conneting (thourhg `SSH`) to the remote machine and invoking the job on it? – user3262424 Apr 15 '11 at 02:57
  • more elegant solution and programmable, you can easily code up what you need using the multiproccessing (or threading) module and rPyC, check http://www.ibm.com/developerworks/linux/library/l-rpyc/ – OneOfOne Apr 15 '11 at 03:03
  • @Ralph: thank you. is there any process / service that needs to be run on the remote machines in order for `RPyC` to be able to connect to them? or can it just connect to any remote machine given its IP? – user3262424 Apr 15 '11 at 03:43
2

Fabric (http://docs.fabfile.org/en/1.0.1/index.html) is a pretty good toolkit for various sys admin and deployment tasks. It comes with a few pre defined tasks but also gives you the flexibility to add what you need.

I highly recommend it.

Tim O
  • 731
  • 5
  • 11
0

Should be able to use Python WMI, for *NIX based systems it's a wrap around SSH and CRON.

Community
  • 1
  • 1
Daniel Protopopov
  • 6,778
  • 3
  • 23
  • 39