The Solaris group is a forum where peers share technical expertise, solve problems, and discuss issues related to the Solaris operating system, including OS-related malfunctions, security issues, and network performance.

Append crontab via a script?

Hopefully this is a rather simple question - i have researched this and can't quite find the answer I am looking for.

I would like to add a crontab entry to 500 or so hosts. Obviously time consuming doing this manually. I would like to know a command which can append or edit the crontab entry via a script or command line.

Popular White Paper On This Topic

You try to append this line into which user crontab? Just see files in
(uhh... if I remember) /var/adm/crontabs . If it will be root's corntab
- just echo "<YOUR_LINE>" >> /var/adm/crontabs/root (please check - path
- I'm now not on system and can wrong.

You can do this in a script.
1. Can you run rcp and remsh from a common system to all of the other
systems?
use rcp and remsh
2. Can you run scp and ssh from a common system to all of the other systems?
use scp and ssh

If the answer to either is yes, you can do this in a script. YOU MUST RUN
AS ROOT!!

Create a file containing all of the remote system names where you want the
line appended.

The other suggestions so far will work, but some caveats:
- You shouldn't just append lines directly to the crontab file or cron
won't pick up the changes. Worse, if you have BSM auditting turned on,
all of that users cron jobs will stop working.
- If you blindly append lines to the end of the crontab, you might end
up with duplicate jobs (if the job already exists).

I always have the problem of telling them too much or not enough. How much
do they already know. It would be a lot easier if we could just logon their
systems and fix the problem.

We run a network of 300+ Sun servers, 200+ HP workstations and 50+ Linux
servers, along with however many PC that out users connect to our network..
Managing user accounts and OS upgrades, one system at a time, is just too
much work. Therefore, we do a lot of management across the network from a
central admin server. ssh is my friend and we don't let users use cron.
This way we can control the crontab files from a central location. We make
our users and application developers use Appworx rather than cron. This
puts the onus on them rather then us.