- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: crontab -e options....
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2001 11:35 PM
11-24-2001 11:35 PM
I am trying to fix a cron job to redirect std out to dev null as adviced on another post.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5ad89200caded5118ff40090279cd0f9,00.html
Now I have this cron job in about 40 servers. Is there a way I can edit/add/delete one cron job though a remote shell or another way so I dont have to log in and fix everyone by hand?
Thanks,
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2001 01:21 AM
11-25-2001 01:21 AM
Solutionsounds tricky, you will have to be very sure no-one else is editing a crontab on anyone of the servers.
You could try to remsh the following (I did not test/try this, that's up to you ;) :
crontab -l > /tmp/oldcron
ed /tmp/oldcron << [EOT]
,g;yourscriptname;s;$; > /dev/null 2>&1
w /tmp/newcron
q
[EOT]
crontab /tmp/newcron
The $ probably has to be escaped (\$), not sure yet : not really awake yet ;)
good luck,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2001 01:26 AM
11-25-2001 01:26 AM
Re: crontab -e options....
it is possible:
crontab -l >crontab.org (to get cuttent crontab)
cat new_cron_lines >>crontab.org (appends lines)
# crontab corntab.org (loads new crontab)
Put this in a SD kit (configure script), or ftp to all servers and run this script with remsh.
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2001 01:27 AM
11-25-2001 01:27 AM
Re: crontab -e options....
I think you can use rsh or remsh to do this job. But then you have to modify the .rhosts file on all the servers. I would have suggested the format too, but won;t be able to do so now as i'm at home and can't connect to my server.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2001 05:49 AM
11-25-2001 05:49 AM
Re: crontab -e options....
Since this is a root crontab, i guess you would be having full control over it, so should have the flexibility on when to change it.
On one Base system, edit, modify and implement the crontab script.
(eg:#login as root
# crontab -l >/tmp/rootcron.old
# cp /tmp/rootcron.old /tmp/rootcron
#vi rootcron (make changes)
#crontab /tmp/rootcron (implement it)
#make sure it is fine
)
Now, you can do the same on remaining systems remotely, only if you already have the .rhosts set up!
Otherwise, you would still need to login to
each of those boxes and set the .rhosts file!,
which is as good as logging into the system
and running the crontab commands ;-)
I think it is good to set up some mechanism
(.rhosts, or ssh keys ) between systems to
make transfer of files or running of remote
commands easier. This is especially needed when dealing with many systems in a site.
So, probably this is the right time to do it.
If you are not comfortable in opening remsh ports, setup secureshell.
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2001 07:25 PM
11-25-2001 07:25 PM
Re: crontab -e options....
May I suggest that the first thing your remsh does is to copy the root crontab to a safe location on each server.
If you are simply adding the same entry to each server I'd write a script that:
cd /var/spool/cron
cp -p crontabs/root root.`date`
crontab -l >root.new
echo "new crontab entry" >>root.new
crontab root.new
Then I'd create a file containing the hostnames of each of the other servers (one server per line).
Then I'd do:
for host in `cat list.of.hosts.file`
do
rcp script#1 $host:/var/tmp
remsh $host /var/tmp/script#1
done
Test this on one server before running on all. You may have to play with the permissions. As others have said, you need to have .rhosts configured for root on each server.
One word of caution concerning all systems having .rhosts set up for root. If the system that is allowed to remsh (no password) to the rest of the servers is compromised, all your servers are compromised. In my opinion, root login should be limited to the console and definitely root rlogin without a password should not be used.
My 2 cents.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2001 07:27 AM
11-26-2001 07:27 AM
Re: crontab -e options....
1) automating the editing of root's cron.
2) automating a change that must be done on multiple servers.
For #1: This is what I do:
crontab -l | grep -v "something unique in the cronjob I want to change/add" > /tmp/cron.root
NOTE: This means I really don't need to worry in the cron entry existed before or not, I can now add the entry I want.
echo "* * * * /opt/something/runit >/dev/null 2>&1" >> /tmp/cron.root
crontab cron.root
I'd put the above entries in a little script.
Now for #2: You can use rsh, SSH, expect, or some 3rd party software distribution tool. Another option would be to make a depot out of this and use an Ignite server to distibute it.
My choice, use ssh, first use scp to place the little script in /tmp on each server and then ssh root@servername /tmp/myscript to execute it. If you have that many servers to administrater its worth the effort to have ssh setup this way to make changes on your servers. Just make sure to protect the keys and limit the locations where it can be run from. This is also a handy way to change root passwords.
Good luck