LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-11-2009, 01:34 PM   #1
schwing
LQ Newbie
 
Registered: Oct 2003
Location: Michigan, USA
Distribution: YellowDogLinux & Debian Sarge
Posts: 14

Rep: Reputation: 0
sftp: run command after user exits?


I have a server where my users sftp and drop files. I also set up a backup server where the sftp server rsyncs to. My problem is that the are around 100GB of files that I would like to keep in sync between the servers. The first sync took a few days to complete, but now each time it runs it takes almost 30 minutes creating the file list.

My thought to speed this up would be to have sftp run a specific rsync command on the user's directory to transfer only the files they sftp'd to the backup server. Then once a night I could run the "full" rsync to make sure nothing is missed.

Could someone tell me how I could run a script after the user has logged out? My users are mainly Windows users using a GUI client so asking them to do anything on their end is not really an option.

-ken
 
Old 11-12-2009, 08:00 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
hmm. still no answers. What about writing a script in shell or perl that runs as a daemon and watches the log files? When an entry shows that a user has transferred files, run rsync on their home directory. There are some tricks to this. You have to make sure the logging level is such as to give you what you need, and you need to know how to read the added tail on a log file (keep your place when another program has written to the file).

Another shot in the dark might be to figure out how openssh connects with its sftp module (not the same as /usr/bin/sftp, possibly /usr/libexec/sftp-server?). If that is a binary that is called when someone does an sftp, you could move it to, say, sftp-server-real, and put a script in its place that calls it and then does the rsync. I've done that with some other sorts of things, like the lp binary, but I don't know if the ssh/sftp connection is amenable to that approach. One difficulty here is figuring out how to get the user who was running it. You might try doing a sizable scp and then looking at processes on the server side to see what it is doing. There is likely to be a root process and a process under the name of the user doing the scp.

Anyway, if nobody comes in with any more concrete ideas, those are a couple of things you could poke at and think about.
 
Old 11-12-2009, 10:11 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,287

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
How about inotify or dnotify?
 
  


Reply

Tags
rsync, sftp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create sftp user only in red hat 4 not ftp user ..only sftp user princeu28 Linux - Newbie 1 10-14-2008 08:10 AM
run a command as another user!! mike81 Linux - Newbie 7 08-02-2006 12:58 PM
run command as user BFEINZIMER Linux - Newbie 9 08-24-2005 10:21 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
run mount command as user paul_mat Linux - Newbie 1 12-14-2004 06:28 PM


All times are GMT -5. The time now is 03:02 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration