Cron Job to login and run one command and logout

I am wanting to create a cron job on Fedora core 8 that logs into a 7 of our network devices, and runs one command that pushes the database backup to an ftp server, and then logs out. Can anyone help me with this? Thanks in advance
LVL 4
buckethead34Asked:
Who is Participating?
 
omarfaridCommented:
0
 
omarfaridCommented:
please the below link on how to run ftp through crontab:

http://www.experts-exchange.com/OS/Linux/Q_23357010.html
0
 
Deepak KosarajuDevOps EngineerCommented:
I need more details! logs u mean login, if so what type of login it is? I mostly recommend configure password less login if possible.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
arrkerr1024Commented:
The easiest way to run a command on a remote server is to use ssh.

In order to log in with out a password, you need to have the public key from the source machine in the authorized_hosts file on the target machine.

On the source machine (the machine running the command) see if you have ~/.ssh/id_dsa.pub or ~/.ssh/id_rsa.pub.  Those are public SSH keys.  If not, run "ssh-keygen -t dsa", which will create ~/.ssh/id_dsa.pub.

On the target machine create .ssh/authorized_keys and put the contents of the public key in that file.

Then simply run this from cron:
ssh target "command"

The very first time you run it you will have to accept the target machine's identity, so run it from the command line manually first.  That will make sure it works as well.

Good luck!
0
 
buckethead34Author Commented:
I don't want the job to run ftp, sorry if I was vague. I want the cron job to telnet to a network device and run one command on the box and logout. I'm looking into adding some scripts to do it and expect being in the scripts etc.
0
 
arrkerr1024Commented:
My understanding is that you already have a command on the target machine that created a database dump and puts it on an FTP site.  You just want to be able to run that command from another machine's cron.

Do you also need help constructing the command that does the database dump and puts it on an FTP site?

These should be tackled, if possible, as two separate things.
1) create a script on the target machine that does the database dump and puts it on an ftp site
and
2) create a cron on the source machine that simply logs in to the target and executes the script

You could combine the two, if you need to.. but it'd be an ugly command.
0
 
buckethead34Author Commented:
Just number 2 is necessary a login and a command ran.
0
 
Deepak KosarajuDevOps EngineerCommented:
If u have password less login then use can use the following for loop to login to each network devices and then run the following script.


#!/bin/bash
for i in `seq -w 7`;do echo test$i;ssh test$i"/usr/sbin/backup"; done

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.