- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- setting cron by script.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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
02-16-2005 04:21 PM
02-16-2005 04:21 PM
need ur help to setup cron job on a remote server by script.
rgds
Ankur
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2005 08:12 PM
02-16-2005 08:12 PM
Re: setting cron by script.
You need to create a
...
50 03 16 * * $HOME/scripts/a.sh
55 03 1,10,20 * * $HOME/scripts/b.sh
00 04 1,16 * * $HOME/scripts/b.sh
...
And activate the cron scheduler:
#crontab /usr/spool/cron/crontabs/
Best Regards,
Eric Antunes
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2005 08:20 PM
02-16-2005 08:20 PM
Re: setting cron by script.
Can you expand your question. I think you mean you want to execute a script on one server (server A) which connects to another server (server B) and creates a crontab on that server (B)?
If so, remsh may be your best option to enable you to remotely submit the crontab on server B. Be aware though that this isn't totally secure. As an example (cronjob at 8am everyday):
echo "00 08 * * * /myjob" >/tmp/newcrontab
rcp /tmp/newcrontab SERVERB:/tmp/newcrontab
remsh SERVERB "/usr/bin/crontab /tmp/newcrontab"
Remember, /myjob must be on server B already for cron to execute it!
Give us a little more information if this is not what you require.
All the best - Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 04:06 AM
02-17-2005 04:06 AM
Re: setting cron by script.
remsh hostb "echo '00 08 * * * /myjob' >> /var/spool/cron/crontabs/
remsh hostb /sbin/init.d/cron stop
remsh hostb /sbin/init.d/cron start
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 04:08 AM
02-17-2005 04:08 AM
Re: setting cron by script.
Its usually more trouble to write such a script than it is to log on the machine and simply edit the cron file or run crontab -e.
I endorse the latter approach.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 04:14 AM
02-17-2005 04:14 AM
Re: setting cron by script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 03:19 PM
02-17-2005 03:19 PM
Re: setting cron by script.
I wrote a script, but it doesnt get executed on all HP ux servers (worked fine on some).
i dont know why ? .
Also i dont want to rsh / rmsh commands, also they ask for passwords.
SCRIPT :
for i in `cat servers`
do OS=`ssh $i uname -s`
echo $OS
if [ $OS = HP-UX ]
then
echo "Creating /var/adm/sa $i server"
ssh $i mkdir /var/adm/sa
echo "Setting up cron for $i server"
ssh $i cp -p /var/spool/cron/crontabs/root /var/spool/cron/crontabs/root.1
ssh $i echo "0 * * * * /usr/lib/sa/sa1 600 6" >> /var/spool/cron/crontabs/root.1
ssh $i crontab /var/spool/cron/crontabs/root.1
echo " Present : Crontab -l "
ssh $i crontab -l
elif [ $OS = Linux ]
then
echo "linux Box : $i server"
fi
done
Pls. help
Rgds
Ankur
- Tags:
- ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 06:48 PM
02-17-2005 06:48 PM
Re: setting cron by script.
If you're using ssh to remotely connect and execute commands, make sure you have distributed your public key from the central server to the remote server(s) and added the necessary syntax to the same users $HOME/.ssh/authorization file. If you run the script manually, does it pause when trying to connect to some systems? I would also recommend creating the temporary (new) crontab in /tmp rather than the cron spool directory and submitting it to cron from there.
Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 07:23 PM
02-17-2005 07:23 PM
Re: setting cron by script.
I have distributed the keys and can execute the command w/o password.
This thing doesnt work.
ssh $i echo "0 * * * * /usr/lib/sa/sa1 600 6" >> /var/spool/cron/crontabs/root.1
Why do i need to create a tmp directory.
Waitn for ur help.
Rgds
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 07:30 PM
02-17-2005 07:30 PM
SolutionTry this instead:
ssh2 -l username server "echo 'blabla bla bla' >/tmp/me"
(obviously modified to your command) - the quote for the exho is the one under the @ sign!!
Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 07:40 PM
02-17-2005 07:40 PM
Re: setting cron by script.
ssh $i "cp -p /var/spool/cron/crontabs/root /var/spool/cron/crontabs/root.1"
ssh $i "echo '0 * * * * /usr/lib/sa/sa1 600 6' >> /var/spool/cron/crontabs/root.1"
ssh $i "crontab /var/spool/cron/crontabs/root.1"
All the best - Keith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2005 10:13 PM
02-17-2005 10:13 PM
Re: setting cron by script.
I hope to be like u ;-}
rgds
Ankur