LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-21-2006, 12:07 PM   #1
nazs
Member
 
Registered: Apr 2005
Posts: 57

Rep: Reputation: 15
Cronjob / script question


Hi All,
I have many location servers that we do nightly backups on and then scp the file to a central server. I have created a user on each server and added their public keys to the central server. I would like the cronjob to be run as root. But in the script su to the username that was created so it can scp with no password because of the public keys. This is what I tried to use but it does not work. Could you please suggest changes that should be made.

#!/bin/sh

su joesomebody \
scp \
/usr/local/var/backup7pm/joesomebody-backups* \
joesomebody@xfer.someplace.com:/backup/

Thank you,
Nazs
 
Old 12-21-2006, 01:45 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
su user -c "command line"

So,

su joesomebody -c " \
scp \
/usr/local/var/backup7pm/joesomebody-backups* \
joesomebody@xfer.someplace.com:/backup \
"

should work in bash.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sftp script via cronjob ?? OzTEXS Linux - Security 21 12-28-2006 03:38 PM
cronjob php script MrSako Linux - General 1 08-27-2006 07:30 PM
cronjob not working but script works dtra Linux - Newbie 4 02-28-2005 05:05 PM
cronjob help meeh Linux - General 1 03-26-2004 11:41 AM
Cronjob question jungsonn Linux - Newbie 3 03-22-2003 09:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration