Deploying Cronjob to multiple servers

I figure that this is a shell scripting issue so I'll post here.

I'm attempting to deploy a cronjob to a variety of servers, some 200-odd, of all walks of life. Mostly AIX, but some Solaris, some HP-UX, some Linux (of varying distributions), etc. I initially thought about utilizing a mass deployment with a scripted rsh or ssh command, echoing in an appended line that contained the cronjob and executing a refresh/restart of the cron service. But that won't work, so I'm stuck with another method, utilizing a vi command. This is supposed to be doable but I'm having some trouble visualizing it. If someone could get me started in the right path that would be great, or provide a script that they've used in the past.

Secondly, if simply echoing/inline editing crontab entries won't work, what will I need to do if I need to edit the file after the initial deployment and adjust the entry for whatever reason (syntax error, change the execution time/date, etc.)? A friend of mine suggested using a perl script that invokes a vi-style search-and-replace function but will these changes be seen by cron on these systems or not? If not, is there another method recommended?

Create an ed script, call it mycron:

1a * * * * * /path/to/myscript > /tmp/logfile 2&>1
.

/var/spool/cron/crontabs is the directory for Solaris crontabs. You will need an OS-specific variant of the script below.

This script assumes you are able to write the crontab, and that you have ssh keys installed. It also makes a lot of assumptions about your boxes - ie all of the solaris boxes have the same usernames, permissions, etc.

#!/bin/ksh
#ip.dat is a list of nodes of one flavor of OS
while read nname
do
sftp $nname <<EOF
   put mycron
   exit
EOF
ssh $nname '(cat mycron %&& echo "w" ) | ed - /var/spool/crontabs/someusername'

vi is based on ed. ed will not break your crontabs. Do not put too much faith in my example ed script, test it first.

Thank you for the reply.

It doesn't quite answer my original question. The big one: will any changes done to the crontab file manually (through ed/vi/echoing text in/etc.) cause cron to see those changes? I've been told by our SME that they won't, at least not in Solaris. What about other OSes, like AIX, Tru64 or Linux?