Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab automation

Status
Not open for further replies.

stu78

Programmer
May 29, 2002
121
0
0
GB
Hi,

I am trying to create a crontab file for one user which must be replicated across sevaral servers, I want to script this;

This is what I have, is there a better way?

echo "newuser" >> /etc/cron.d/cron.allow
touch /var/spool/cron/crontabs/newuser
chown -R root:sys /var/spool/cron/crontabs/newuser
echo "45 23 * * * $HOME/bin/log.ksh 0 0,2,4,6,8,10,12,14,16,18,20,22 * * *" /var/spool/cron/crontabs/newuser


I think if I could do a

echo "newuser" >> /etc/cron.d/cron.allow
crontab -e newuser

Insert the job & fall back out of the shell, this would be neater... can anyone suggest?
 
Stu, I'm sure there has been a recent thread either in this forum or one of the other *nix fora dealing with a similar issue. I'm afraid I've been unable to find it with a search but others might remember better than I. What I would advise at this stage would be not to use crontab -e directly, just make a copy of it for safety and append your command to that using [new line to be included] >> [newcrontabname]. You can then activate it using crontab [newcrontabname] rather than editing a good existing crontab which works.
 
Hi,

if you do not use crontab command, you should restart cron manually.
/etc/init.d/cron stop
/etc/init.d/cron start

however you can still use crontab command with filename option.

First you should allow root to login as newuser

echo "<server name> root" /export/home/newuser/.rhosts or where the newuser home directory

echo "newuser" >> /etc/cron.d/cron.allow
echo "45 23 * * * $HOME/bin/log.ksh 0 0,2,4,6,8,10,12,14,16,18,20,22 * * *" /tmp/newuser

rsh -l newuser <server name> crontab /tmp/newuser

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top